This script for AHK v2:
msgbox 1.0009
Shows this value in the msgbox:
1.0008999999999999
EDIT: Tried this in AHK v2-a112 and a108 ... same thing.
I tried this in AHK v1.1.33:
msgbox % 1.0009
And the expected 1.0009 is displayed.
Float - something wrong - AHK v2-a116 Topic is solved
Re: Float - something wrong - AHK v2-a116 Topic is solved
https://lexikos.github.io/v2/docs/Concepts.htm#numbers wrote:Floating-point numbers are formatted with full precision (but discarding redundant trailing zeroes), which may in some cases reveal their inaccuracy.
Re: Float - something wrong - AHK v2-a116

my bad.
« Portable AHK Installer » | « CallTipsForAll » | « All Scripts by TheArkive » | « TheArkive on GitHub »
Re: Float - something wrong - AHK v2-a116
The equivalent script for v2 ismsgbox % 1.0009
Code: Select all
msgbox "1.0009"
All literal numbers are converted to pure binary numbers at load time and their string representation is discarded. For example, MsgBox 0x1 is equivalent to MsgBox 1, while MsgBox 1.0000 is equivalent to MsgBox 1.0 (because the float formatting has changed). Storing a number in a variable or returning it from a UDF retains its pure numeric status.
Source: v2-changes
Re: Float - something wrong - AHK v2-a116
Thanks @lexikos, looks like i gotta slow down and read more.
« Portable AHK Installer » | « CallTipsForAll » | « All Scripts by TheArkive » | « TheArkive on GitHub »
Return to “AutoHotkey v2 Help”
Who is online
Users browsing this forum: No registered users and 2 guests