caffeine_demon
Board Regular
- Joined
- Apr 19, 2007
- Messages
- 64
Hi,
So - I wanted to find a way of counting the number of decimal places in a number, so my idea was:
- Subtract the "int" part of a number from the number. (Ie a1-int(a1) ) - giving just the decimal value
- use "len" to calculate the length of that, and subtract 2 (for the 0, and the decimal point) - (so - Len(a1-int(a1)) - 2 )
I was getting strange results, if we start with :
A1 = 2.05
A2 = Int(a1)
A3 = A1-A2
a4 = len(a3) -2
a2 results in "2" - as expected, a3 shows "0.05" - as expected, but a4 is saying the length is 16. Going into the formula wizard, it tells me the value of A3 is "0.49999999999989" (there may be more 9s)
trying values from 2 up to 4 (in steps of 0.01) - it appears only 2, 3 and 4 give the correct result
Also - if I just enter the formula "Len(2.05-2) -2" , that also gives 16.
Is there something I've missed, or have I found a bug? is there a better way to calculate the number of decimal places?
(This is office pro 365 at work)..
Thanks.
So - I wanted to find a way of counting the number of decimal places in a number, so my idea was:
- Subtract the "int" part of a number from the number. (Ie a1-int(a1) ) - giving just the decimal value
- use "len" to calculate the length of that, and subtract 2 (for the 0, and the decimal point) - (so - Len(a1-int(a1)) - 2 )
I was getting strange results, if we start with :
A1 = 2.05
A2 = Int(a1)
A3 = A1-A2
a4 = len(a3) -2
a2 results in "2" - as expected, a3 shows "0.05" - as expected, but a4 is saying the length is 16. Going into the formula wizard, it tells me the value of A3 is "0.49999999999989" (there may be more 9s)
trying values from 2 up to 4 (in steps of 0.01) - it appears only 2, 3 and 4 give the correct result
Also - if I just enter the formula "Len(2.05-2) -2" , that also gives 16.
Is there something I've missed, or have I found a bug? is there a better way to calculate the number of decimal places?
(This is office pro 365 at work)..
Thanks.