Answer the question
In order to leave comments, you need to log in
How to convert fractional numbers from binary to 10 in c++?
You need to write a code for converting fractional numbers from 2 to 10
Answer the question
In order to leave comments, you need to log in
You can do so. Create two variables: double x=0, y=0.
Read the line from left to right. If the digit came b=='0' or '1', then execute x=2*x+b-'0'; y*=2;
If a comma came - assign y=1. Finally, if y is non-zero, then divide x by y.
For example,
for line 101 : x=5, y=0. Answer 5.
101.101 : x=45, y=8. Answer 45/8=5.625
101, : x=5, y=1. Answer 5.
,101 : x=5, y=8. The answer is 5/8=0.625.
Floating point/point numbers then.
Here is the IEEE 754 standard for you if you are completely banned in Google.
Convert to binary, and then rotate as you please, even in hex, even in octal with ternary.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question