#185117 - 2008-02-06 09:54 PM
"Rounding" bug incrementing a variable by 0.1
|
Jochen
KiX Supporter
   
Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
|
break on
@kix ? ?
$dbl = 0.0
while $dbl < 15
$dbl = 0.1 + $dbl
$dbl ?
loop
get $
This one shows a whacky rounding behaviour both in 4.53 and 4.60 (both kix32 and wkix32) when it reaches 5.9 and adds 0.1 (no matter if $dbl is 0 or 0.0 or (not) implicitly/explicitly declared before the loop)
Output on Windows XP Professional SP2 (German standard regional settings, therefore the comma in the output) :
4.60
0,1 0,2 0,3 0,4 0,5 0,6 0,7 0,8 0,9 1 1,1 1,2
... normal output, until:
5,7 5,8 5,9 5,99999999999999 6,09999999999999 6,19999999999999 6,29999999999999 6,39999999999999 6,49999999999999 6,59999999999999 6,69999999999999 6,79999999999999
... the bug persists until it suddenly goes back to normal at 10
9,79999999999998 9,89999999999998 9,99999999999998 10,1 10,2 10,3 10,4 10,5
_________________________
|
|
Top
|
|
|
|
Moderator: ShaneEP, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Ruud van Velsen, Mart
|
1 registered
(Allen)
and 1198 anonymous users online.
|
|
|