Hello, I received a question whereby I had to convert to fractional decimals to binary.

0.28125 and 0,65625

Using the methods taught me to convert them to fractional binary I got .01001 and .10101 respectively.

Next we were required to add the two binary fractions, which my answer was: .11110

Then we were asked to convert this binary fraction decimal. This I do not know how to do. Can anyone please tell me how to do this if they know?

Thanks
-Airman

You figured out the hard way, and now you're having trouble with the easy way?

Hello, I received a question whereby I had to convert to fractional decimals to binary.

0.28125 and 0,65625

Using the methods taught me to convert them to fractional binary I got .01001 and .10101 respectively.

Next we were required to add the two binary fractions, which my answer was: .11110

Then we were asked to convert this binary fraction decimal. This I do not know how to do. Can anyone please tell me how to do this if they know?

Thanks
-Airman

Answer #1: cheat! :)

#! /bin/bash
  bin1=".01001"
  dec1=`echo -e "ibase=2\n e(l(${bin1}))" | bc -l`
  bin2=".10101"
  dec2=`echo -e "ibase=2\n e(l(${bin2}))" | bc -l`
  bin3=".11110"
  dec3=`echo -e "ibase=2\n e(l(${bin3}))" | bc -l`
  echo "$bin1 => $dec1"
  echo "$bin2 => $dec2"
  echo "$bin3 => $dec3"

Answer #2: not really an answer, but might provide a clue or two.

Decimal:
  1000  100  10  1  .  1/10  1/100  1/1000 ...

Binary:
     8    4   2   1  .  1/?   1/?    1/?    ...
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.