0

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

3
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by Fest3er
0

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/?    ...
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.