Questions tagged [base-conversion]

Base conversion is the process of changing the base of the textual representation of a number to another base. For example, "1010" in binary to "10" in decimal is a base conversion.

Base conversion is the process of changing the base of the textual representation of a number to another base. For example, 1010 in binary to 10 in decimal is a base conversion.

198 questions
0
votes
2 answers

Java Base Conversion with addition

How would I do 10101base2 + 111base2 =? I already know how to convert the base to another base. But how would I do them with addition?
0
votes
3 answers

Base converter binary to octal

I'm writing a base converter because I have a test soon and I need to convert a binary number in 3 different bases: octal, decimal and hexadecimal. I've already written the code that convert a binary string into decimal and hexadecimal. function…
Alberto Rossi
  • 1,800
  • 4
  • 36
  • 58
0
votes
2 answers

base 16 to base 2^64 conversion in GMP

I read in some hex numbers and I then would like to convert them to base 2^64. Unfortunately as this number cannot be stored in an int, it seems there is no function in GMP that can help me solve this problem. Is there another way to do this that I…
0
votes
2 answers

Trying to reproduce a dechex() function behaviour on x64 architecture

The example #2 of the PHP manual page of the dechex() function is the following : // The output below assumes a 32-bit platform. // Note that the output is the same for all values. echo dechex(-1)."\n"; echo dechex(PHP_INT_MAX * 2 + 1)."\n"; echo…
Alain Tiemblo
  • 36,099
  • 17
  • 121
  • 153
0
votes
1 answer

Convert hex to decimal in make script?

A make script is attempting to set a variable as follows: VER_DEC=$( perl -e "print hex(\"$(VER_HEX)\");" ) where VER_HEX happens to have a value of 0a. Perl seems to think that VER_HEX is zero, implying that the variable isn't set (but it is,…
system PAUSE
  • 37,082
  • 20
  • 62
  • 59
0
votes
1 answer

Converting non-decimal numbers to another non-decimal

Not that it's a lot of work, but the only way I know to convert a non-decimal to another non-decimal is by converting the number to decimal first, then take a second step to convert it to a new base. For example, to convert 456 (in base 7) to 567…
Haoest
  • 13,610
  • 29
  • 89
  • 105
0
votes
1 answer

What does base -2 mean?

Can anyone help me understand what is base -2? I understand base in positive integers and know how to convert a decimal number to those bases, but really do not have any idea with negative base.
Will Best
  • 211
  • 1
  • 3
  • 6
0
votes
2 answers

Converting ASCII hex number to 32-bit binary integer in x86

So im reading the user's 8-digit input, and saving it into a variable. for example: Enter an 8-digit hex number: 1ABC5678 So, then i loop through the 1ABC5678 hex number and subtract 48 from numbers 0-9 and subtract 55 from A-F to have a number…
Shar
  • 13
  • 1
  • 5
0
votes
1 answer

Base conversion for array of fractional places

I am trying to implement an algorithm to convert an array of integers, which represent the digits of the fractional part of a number, from one base to another. In other words: int[] input = {0, 0, 1, 0, 1}; // 0.00101 in base 2 int[] output =…
hgcrpd
  • 1,820
  • 3
  • 19
  • 32
0
votes
3 answers

PHP returns floats instead of strings from a database?

I use this to create a unique code for each product in my store, echo base_convert(uniqid(),16,10); For instance, 1403802682572650 My query is simple like this, $sql = " SELECT * FROM page AS p LEFT…
Run
  • 54,938
  • 169
  • 450
  • 748
0
votes
2 answers

Base number converter from 10 base with recursive function - C

I try to convert any number base from 10 base. After I multiply two numbers that the same base, but the function should be recursive. double convert(int number,int base) { int digit = 1; double sum=0; int i=0; int figure; …
nevra
  • 418
  • 1
  • 7
  • 21
0
votes
2 answers

How do I convert a Hexa-Tri-Decimal number into an int in objective c?

The Hexa-Tri-Decimal number is 0-9 and A-Z. I know I can covert from hex with a NSScanner but not sure how to go about converting Hexa-Tri-Decimal. For example I have a NSString with "0XPM" the int value should be 43690, "1BLC" would be 61680.
Justin808
  • 20,859
  • 46
  • 160
  • 265
-1
votes
1 answer

Convert any base to decimal using Horner's recursively

I have to write a program converting from any base to decimal using recursion and Horner's scheme. All I can use is: an int method with two parameters like public static int horner (int[] digits, int base){}. I have to implement the method…
Msitake
  • 13
  • 2
-1
votes
3 answers

Hex to Dec conversion with printf in sh fail for more than 16 digits

I only have shell available no bash, Perl, python etc. Using printf small numbers work: root@DD-WRT:/jffs# printf "%d\n", 0x15a 346 But large numbers fail. root@DD-WRT:/jffs# printf "%d\n", 0x15abc12345afda325 sh: invalid number…
Crankdat
  • 11
  • 5
-1
votes
1 answer

Converted 0.4 from base 10 to base 2, but the result isn't correct even though the procedure is right

I am trying to convert 0.4 from base 10 to base 2. This is what I did: 0.4 * 2 = 0.8 0.8 * 2 = 1.6 0.6 * 2 = 1.2 0.2 * 2 = 0.4 0.4 * 2 = 0.8 0.8 * 2 = 1.6 Because 0.8 and 1.6 are repeated, I stop right here, and "0110" is what I got. But, 0.0110…