Modify ↓
Opened on Feb 8, 2010 at 1:45:24 AM
Closed on Feb 8, 2010 at 2:02:46 AM
Last modified on Feb 8, 2010 at 2:56:47 AM
#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 , on Feb 8, 2010 at 2:02:46 AM
| Resolution: | → No Bug |
|---|---|
| Status: | new → closed |
comment:2 by , on Feb 8, 2010 at 2:56:47 AM
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)
Note:
See TracTickets
for help on using tickets.

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.