M HYPE SPLASH
// general

How to convert decimal with scientefic notation, to binary?

By Emma Terry
$\begingroup$

I have number $-1e35$, and I'm supposed to convert it to binary. The answer is :$-1.10101001010110100101101...\text{e}–117.$

I can't figure out how to get this! and how we can calculate numbers partially as you see here. Originally it is a programming practice, but what I care about is the mathematical part.

I tried to solve it like this: $\log 10^{35}=\log 2^x.$ The result is: $116.666$.

My question is not exactly how to convert. I know how to convert smaller numbers, but I am confused with scientific notation, and how to represent part of the number.

$\endgroup$ 1

1 Answer

$\begingroup$

When you represent a number in decimal scientific notation, the base of the exponent is $10$, so $1E35=1\cdot 10^{35}$. In binary, the base is $2$, so you are trying to solve $1\cdot 10^{35}=m2^e$ where $1 \lt m \lt 10_2$ is the mantissa and $e$ is an integer exponent. To find $e$ we can take logs:$$1 \cdot 10^{35} = m2^e\\ 35 \log_2(10)=e+ \log_2 (m)\\e=\lfloor35 \log_2(10)\rfloor=116_{10}$$Now to get the mantissa you can just subtract off powers of $2$$$10^{35}-2^{116}=16923250263442757943512058732478464\\ \lfloor \log_2(16923250263442757943512058732478464)\rfloor=113$$so we start with $1.001_2$ because the exponent dropped by $3$$$16923250263442757943512058732478464-2^{113}=6538656546373102686451066074038272\\ \lfloor \log_2(6538656546373102686451066074038272)\rfloor=112$$so our mantissa becomes $1.0011_2$ and so on until you get tired, your word fills up, or you get to the end. The final answer is $$1.001101000010011000010111001011000111010011011000001000101011100001111000111111101_2E116$$

$\endgroup$ 11

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy