Similar to decimal binary numbers can have represent floats too. Now I read that it can have floats of the sort
0.5:0.1 , 0.25:0.01 , 0.125:0.001 … and so on. But then, for example, how is the 0.1(in decimal) represented in binary?
Also, given a decimal float, how to convert it to the decimal equivalent, (given it is not so straightforward).
Edit: So I understand that the better question would have been ; how to convert a decimal float to binary? Now i get it that we multiply the decimal part, till it becomes zero.
Now it is very much possible that two floating points can have the same representation right?
Given how many bits?
0.1b:
As you can see it’s an approximation.
Each bit after the radix point represents 1/2^(position_after_bit_string).
So
0.0000001 = 1/2^7 = 0.0078125Pseudocode:
For more info Why can't decimal numbers be represented exactly in binary?