Modify

Opened 12 years ago

Closed 12 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 Changed 12 years ago by rbhkamal

I'm rbhkamal... not anonymous

comment:2 Changed 12 years ago by Valik

  • Resolution set to No Bug
  • Status changed from new to closed

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.

Guidelines for posting comments:

  • You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
  • In-depth discussions should take place on the forum.

For more information see the full version of the ticket guidelines here.

Add Comment

Modify Ticket

Action
as closed The ticket will remain with no owner.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.