How can I count how long the floating point is?
e.g.
count(10.123); //result: 3
count(10); //result: 0
count(10.3771) //result: 4
I know how to count it when transforming to a string, but that isn't very efficient, is it?
How can I count how long the floating point is?
e.g.
count(10.123); //result: 3
count(10); //result: 0
count(10.3771) //result: 4
I know how to count it when transforming to a string, but that isn't very efficient, is it?
A double
is always a specific length. It will only show the numbers need to obtain the accuracy.
ie. 10.3771 is the equivilant to 00000010.37710000 (not the exact number of 0's that are really there, I'm just trying to explain the concept).
In reality even this is inaccurate as a double
is a 64 bit binary number
Converting it to String
is your best bet and not an inefficient method.