Here is the Example:
For example, suppose we have a float 13.4
. In binary, it can be written as: 1101.01100110011001100110011001100110011兮
.
Suppose the system stores bits up to 10
decimal places. So 13.4
is stored as: 1101.0110011001
(only 10
decimal places now)
Because of this change, if you convert 1101.0110011001
back to base 10
, you get 13.399414
. In essence 13.399414
is stored rather than 13.4
in this case!
So given a floating point in base 10
, an integer n
which represents the number of decimal places as defined above, output the stored value of the float to three decimal places.
So How can i convert using javascript:- input 13.4
and output 13.399