I am totally new to mathematica but started learning how to use it. I use the following function to convert a decimal number into its binary representation.
binExp[num_, d_] := First[RealDigits[N[num, d], 2]];
Currently, I am stuck with two points:
If I type
binExp[240, 7], I get a 23-bit binary representation of a decimal number in the interval[0,255]BUT I need a 24-bit binary representation of it.I have a
100,000decimal numbers stored in a text file and want to use the previous function within mathematica to convert all of them to their 24-bit binary representation and store them back in a text file.
Any help is appreciated.
7but sinceN[Log2[10^7]]is approximately23.2535you can only expect to find the first 23 digits this way. You would need a precision of at leastLog10[2^24]. – Heike Feb 6 '12 at 12:48binExpfunction and use doesn't make a lot of sense. – Mr.Wizard♦ Feb 6 '12 at 18:36