Opened 14 years ago

Closed 14 years ago

Last modified 14 years ago

#1460 closed Bug (No Bug)

This says $x<>1 but it shows that it is

Reported by: Beege Owned by:
Milestone: Component: AutoIt
Version: Severity: None
Keywords: Cc:


This msgbox should not appear

$x = 0.7
$x += 0.1
$x += 0.1
$x += 0.1
If $x <> 1 Then MsgBox(0, '$X<>1', '$X = ' & $x)

Attachments (0)

Change History (2)

comment:1 Changed 14 years ago by Valik

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

Sigh. Floating point numbers are imprecise, blah blah blah. Seriously, I've covered this about a billion times. Try using Int($x) to do a tiny bit of floating-point correction to account for the inaccuracies or don't use floating point arithmetic and then expect the results to be what you want.

Nothing to see here.

comment:2 Changed 14 years ago by Beege

I guess I was always under the impression that I would be shown the true value if it was some kind of a float. Like in this example, the same kind of miscalculation happens only the msgbox will display the true value $x = 6.99999999999999. Not evaluate that it is not 7 and then show me that the value is 7. Anyway, sorry for the mistake.

$x = 5
For $i = 1 to 20
    $x += .1
if $x <> 7 Then MsgBox(0, '', $x)

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

as closed The ticket will remain with no owner.

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

Note: See TracTickets for help on using tickets.