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

Convert from base 10 to base 3

I have a whole column in Google sheets with the numbers 1-400. Is there an easy way to convert these numbers to base 3?
Max
  • 33
  • 3
3
votes
2 answers

How to convert a number to an arbitary base in perl?

I would like to do something like the following in perl: @digits = ("1", "2", ..., "a", ... "z", ... ); ## a list of characters $num = 1033; convert_to_base($num, @digits); Now, $num will be converted to a string with the digits being used are from…
kloop
  • 4,537
  • 13
  • 42
  • 66
3
votes
3 answers

Pythonic way to do base conversion

I am a complete beginner to Python. I wrote some code to perform base conversion and I was wondering if there were better alternatives that were shorter to code (one-liners) or significantly faster. The code looks ugly and feels "non-Pythonic"…
saltekar
  • 71
  • 1
  • 4
3
votes
2 answers

Double to base 2 conversion (is there a simple way?)

Hi and thanks for helping, (Working with Java) I've looked around a bit for converting a Double to base 2 (still in double) but I could not find a simple way. I read that given how Doubles were coded the methods like Double.doubleToRawLongBits() can…
NaC114
  • 83
  • 8
3
votes
1 answer

Computing the Factoradic Rank of a Permutation (N choose K)

I've recently learnt about CNS and FNS, and since they look so elegant to me, I decided to try and implement methods to generate combinations and permutations using those techniques. I finished my method to convert from n choose k combinations to a…
Alix Axel
  • 151,645
  • 95
  • 393
  • 500
3
votes
2 answers

Hex decimal to float Python

I'm reading data from a binary file. I have a document that lets me know how the information is stored. To be sure of this I use XVI32. I was extracting information string and int data correctly, until I bumped with float data type. According to…
Hugo Medina
  • 351
  • 1
  • 2
  • 9
2
votes
2 answers

Convert non terminating binary number to decimal

I don't know how to convert a non terminating binary number(fraction) to decimal . Can anybody guide me how to do with an example?
2
votes
3 answers

Scheme recursion (decimal to octal)

So our class was given an assignment to convert decimal numbers to their octal representations. I managed to just tinker with it till it worked, but I'm having some problems comprehending why it works. Any possibility at explaining the recursion in…
cojennin
  • 71
  • 1
  • 5
2
votes
1 answer

c++ template for conversion between decimal and arbitrary base

Is there a c++ structure or template (in any library) that allows me to do conversion between decimal and any other base (much like what bitset can do) ?
Tarek
  • 1,060
  • 4
  • 17
  • 38
2
votes
0 answers

Java Base Conversion By BigInteger

In this program I need to be able to take a String and convert it into a base from (2-36) by using BigInteger I'm new to java and I'm trying to find a way to use base conversion by using BigInteger instead of the method below. Although this works as…
Marshme
  • 21
  • 4
2
votes
1 answer

Decode .do URL Request unique ID

I'm building an Excel script that will bypass a form on a website, and parse the request directly in a URL to generate the desired output (then pull that data into Excel). I have everything working, but part of the solution is to include a parameter…
like2think
  • 142
  • 2
  • 15
2
votes
1 answer

Efficient base 2 to base 5 conversion

Is there any way to efficiently convert a binary string or file to base 5 without having to store all of the bits in one var as a number? e.g. for base64, you can just make groups of log2(64)=6 bits. EDIT: Thank you for your answers, but I'll…
alexbrt
  • 31
  • 4
2
votes
2 answers

Store SHA-1 in database in less space than the 40 hex digits

I am using a hash algorithm to create a primary key for a database table. I use the SHA-1 algorithm which is more than fine for my purposes. The database even ships an implementation for SHA-1. The function computing the hash is returning a hex…
MaNa
  • 51
  • 6
2
votes
2 answers

Convert Integer to Generic Base Matlab

I'm trying to convert a base-10 integer k into a base-q integer, but not in the standard way. Firstly, I'd like my result to be a vectors (or a string 'a,b,c,...' so that it can be converted to a vector, but not 'abc...'). Most importantly, I'd like…
Sam OT
  • 420
  • 1
  • 4
  • 19
2
votes
2 answers

Integers exhibit odd behavior at higher values

I have created a program, in C#, to convert a number from one base to any other base (e.g. 10 in Base-10 = A in Base-11). For each target base, there seems to be a certain point where the program results in an inaccurate value. E.g., when…
Paul
  • 25
  • 1
  • 6