Modify

Opened 16 years ago

Closed 16 years ago

Last modified 16 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: 3.3.4.0 Severity: None
Keywords: Cc:

Description

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 by Valik, 16 years ago

Resolution: No Bug
Status: newclosed

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 by Beege, 16 years ago

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
Next
if $x <> 7 Then MsgBox(0, '', $x)

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.