Stange problem with sprintf or trace display
- Posted by AJ_Oxley Mar 13, 2012
- 1131 views
Hello gurus...
My app was adding up dollars and cents but did not balance.
A simplified example of why not is given below:
-- euphoria v4.0.3 windows 2011-06-24 13:43:18 with type_check with trace with warning procedure test() atom a1, a2, a3, a4, a5, a6 sequence s1 trace(1) a1 = 0.77 a2 = a1 * 100 printf(1,"\na2 is " & sprintf("%2d",{a2}) & "\n") -- now the strange part a3 = 66.77 a4 = floor(a3) a5 = a3 - a4 -- 0.77, same as a1 a6 = a5 * 100 -- trace says this is 77 printf(1,"\na6 is " & sprintf("%2d",{a6}) & "!\n") -- 76!! end procedure test() -- the problem exists whenever a6 > 01
This is whacky! any ideas?