Modify

Opened 18 years ago

Closed 18 years ago

#502 closed Bug (No Bug)

Autoit adds 0.09999999997 instead of 0.01

Reported by: anonymous Owned by:
Milestone: Component: AutoIt
Version: 3.2.12.0 Severity: Blocking
Keywords: count Cc:

Description

After adding 0.01 to $c few times, $c will be incremented by 0.999999 instead of 0.01

$c = 0
$inc = 0.01

Do
 $c += $inc
Until $c > 14
ConsoleWrite('$c = ' & $c & @crlf)

Output:

+>14:50:40 AU3Check ended.rc:0
>Running:(3.2.12.1):C:\Program Files\AutoIt3\autoit3.exe "C:\Documents and Settings\shithole\Desktop\bug.au3"    
$c = 14.0099999999997
+>14:50:41 AutoIT3.exe ended.rc:0

Windows XP SP3
AutoIt V3.2.12.1

Best regards

Attachments (0)

Change History (2)

comment:1 by rbhkamal, 18 years ago

I'm rbhkamal... not anonymous

comment:2 by Valik, 18 years ago

Resolution: No Bug
Status: newclosed

This is not a bug. Floating-point numbers are not precise so repeatedly adding a floating point number leads to these sorts of problems. You can find plenty of literature on the internet about it.

Modify Ticket

Action
as closed The ticket will remain with no owner.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.