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
2
votes
1 answer

Complex Numbers Seemingly Arising from Non-Complex Logarithms

I have a simple program written in TI-BASIC that converts from base 10 to base 2 0->B 1->E Input "DEC:",D Repeat D=0 int(round(log(D)/log(2),1))->E round(E)->E B+10^E->B D-2^E->D End Disp B This will sometimes return an the error 'ERR: DATA…
ZTqvhI5vpo
  • 155
  • 2
  • 10
2
votes
5 answers

How to reverse integer values from a while loop?

I am trying to write a program to convert a base 10 (decimal) number into a base 4 number. Here is the code I have come up with: def decimal_to_base4(num): while num > 0: quotient = num//4 base4 = num%4 num = quotient …
abruzzi26
  • 159
  • 1
  • 10
2
votes
1 answer

Fastest way to convert between two bases in arbitary precision floating point arithmetic for over a billion digits

Which is the currently the fastest way to convert between base 2 ^ 64 to any other base? By "any other base", I mean any base less than 2 ^ 64 itself. I think it's using Divide-and-Conquer based methods with Bernstein scaled remainder trees? Some…
Syed Fahad
  • 23
  • 3
2
votes
4 answers

Converting binary to base 10 without math.pow( )?

I'm looking to create a simple program that will convert binary numbers to decimal numbers, without using math.pow(). Here's what I have so far, using Math.pow at the end: import java.util.Scanner; public class Question1 { public static void…
user4525741
2
votes
1 answer

What characters does php use for high base numbers?

I know that base 16 uses the characters [0-9a-f], and base 36 uses [0-9a-z], but what about base 40? Base 50? Base [arbitrary number]? How does php determine what characters to use for high-base numbers?
Benubird
  • 18,551
  • 27
  • 90
  • 141
2
votes
1 answer

Number System Conversion - Base 10 to base x using SQL statements only

I want to stop making the same performance mistakes and need someone way steadier on SQL statements than me on this one. Basically I want my function: create or replace FUNCTION SEQGEN(vinp in varchar2, iSeq in INTEGER) RETURN VARCHAR2 is vResult…
wittrup
  • 1,535
  • 1
  • 13
  • 23
2
votes
5 answers

Decimal Division by left shift

I have been given a question to convert base from 10 to 2 without using division(/) and modulus(%), so I came up with solution of using bitwise AND(&) and right shift(>>) operators. So I start to learn what these two operators exactly do but still…
Felix
  • 111
  • 1
  • 2
  • 7
2
votes
1 answer

base_convert numbers map to letters

How can I use base_convert to map numbers to letters? for example 123456 would become ABCDEF. So a number 123321 would become ABCCBA I actually have a unique number, that needs to keep it's uniqueness in the form of a string of letters. Any way to…
gray
  • 798
  • 18
  • 31
2
votes
6 answers

converting from base 10 to base 31 (working only with select characters)

I'd like to convert base 10 numbers to base 31 I would like to use only these characters: 23456789abcdefghjkmnpqrstuvwxyz As you can see, 5 characters are excluded (i don't need these): 1 0 o l i The function I have now is below but of course it…
Chad
  • 2,365
  • 6
  • 26
  • 37
2
votes
1 answer

Negative floating point to binary conversion

I am using the AR Drone SDK to program the drone. In the docs, is says this: The number -0.8 is stored in memory as a 32- bit word whose value is BF4CCCCD(16), according to the IEEE-754 format. This 32-bit word can be considered as holding the…
Ian Herbert
  • 1,071
  • 2
  • 16
  • 35
2
votes
3 answers

Convert Negative-base binary to Decimal in Haskell: "Instances of .. required"

I have to write two functions converting decimal numers into a (-2)adian number system (similar to binary only with -2) and vice versa. I already have managed to get the decimal -> (-2)adian running. But with (-2)adian -> decimal I have a problem…
Jakob Abfalter
  • 4,980
  • 17
  • 54
  • 94
1
vote
2 answers

Why isn't this decimal to binary code not working? I did not want to use arrays or strings

I wrote this code and the output does not match the predicted one. In this case, I took as input n=13 Output I want: 1101 Output I get: 1100 #include #include using namespace std; int main(){ int n; //n is the decimal…
Goshawk
  • 13
  • 3
1
vote
2 answers

Decimal To Binary Conversion in C using For

I am not able to convert from decimal to binary in C.Everytime I get a output which is one less than the desired output.For ex.:5 should be 101 but shows up as 100 or 4 should be 100 but shows up as 99. #include #include void main()…
NewCoder
  • 11
  • 3
1
vote
3 answers

PHP: Will this function always generate a unique string?

Will this following function always generate a unique string? What will be the length range of generated string from the following function? Can it be improved to generate more uniqueness? base_convert(mt_rand(10, 99) . intval(microtime(true) *…
sunjie
  • 2,023
  • 7
  • 28
  • 28
1
vote
3 answers

Reading and setting base 3 digits from base 2 integer

Part of my application data contains a set of 9 ternary (base-3) "bits". To keep the data compact for the database, I would like to store that data as a single short. Since 3^9 < 2^15 I can represent any possible 9 digit base-3 number as a short. My…
captncraig
  • 22,118
  • 17
  • 108
  • 151