POSSIBLE BUG: Floating Point Comparison Issue

Report problems with documented functionality
sirksel
Posts: 222
Joined: 12 Nov 2013, 23:48

POSSIBLE BUG: Floating Point Comparison Issue

26 Jan 2014, 12:32

I love AHK (thanks to Lexikos and all who contribute!), and due to my extensive use of it, every once in a while I notice unexpected behavior like the following:

I would expect the expressions initially stored in gsNum1 and gsNum2 to be equal, but somehow they are not. When this code is run, as you can see in the first line of the first MsgBox, they're testing out as not equal, but their display looks identical. However, once I've done some math on gsNum2, everything works OK in the second MsgBox. Is there a reason for this? Is this behavior that can be modified, because even if not a bug, maybe seems unexpected?

Code: Select all

SetFormat, FloatFast, 0.10
MsgBox % (((gsNum1 := (-1 + Round(((13/24) + (59/1440)), 10))) == (gsNum2 := -0.4173611111)) "`n" gsNum1 "`n" gsNum2)
gsNum2 := gsNum2 + 1 - 1
MsgBox % (gsNum1 == gsNum2) "`n" gsNum1 "`n" gsNum2
Thanks for your help!
User avatar
tank
Posts: 3122
Joined: 28 Sep 2013, 22:15
Location: CarrolltonTX
Contact:

Re: POSSIBLE BUG: Floating Point Comparison Issue

26 Jan 2014, 14:20

We are troubled on every side‚ yet not distressed; we are perplexed‚
but not in despair; Persecuted‚ but not forsaken; cast down‚ but not destroyed;
Telegram is the best way to reach me
https://t.me/ttnnkkrr
If you have forum suggestions please submit a
Check Out WebWriter

Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 15 guests