[v2.0.11] Signed hexadecimal double-precision floating-point value Topic is solved

Share your ideas as to how the documentation can be improved.
Rohwedder
Posts: 7656
Joined: 04 Jun 2014, 08:33
Location: Germany

[v2.0.11] Signed hexadecimal double-precision floating-point value

05 Jan 2024, 12:38

Manual: https://www.autohotkey.com/docs/v2/lib/Format.htm#Types
Quote: For example, Format("{:a}", 255) returns 0x1.fe0000p+7.
Here it returns: 0x1.fe00000000000p+7

(When will Autohotkey be able to calculate mathematically with such hex numbers?)
PI = 3.1415926535897931 = 0x1.921fb54442d18p+1
User avatar
Ragnar
Posts: 614
Joined: 30 Sep 2013, 15:25

Re: [v2.0.11] Signed hexadecimal double-precision floating-point value

05 Jan 2024, 13:43

In v1, this returns 0x1.fe0000p+7. The difference is probably due to the following change mentioned in https://www.autohotkey.com/docs/v2/v2-changes.htm#types:
The default format specifier for floating-point numbers is now .17g (was 0.6f), which is more compact and more accurate in many cases. The default cannot be changed, but Format can be used to get different formatting.
lexikos
Posts: 9592
Joined: 30 Sep 2013, 04:07
Contact:

Re: [v2.0.11] Signed hexadecimal double-precision floating-point value

19 Jan 2024, 07:15

The example is incorrect, but the documentation otherwise doesn't specify the default number of digits. If you want a specific number, you must specify it.

Format("{:a}", 255) internally does the equivalent of _swprintf(target, L"%a", 255.0). The C runtime is entirely responsible for deciding the default precision and doing the formatting. v1 is compiled with Visual C++ 2010, whereas current versions are compiled with Visual C++ 2022. The current documentation for a says "Default precision is 13". I assume that wasn't true for 2010.

The "default format specifier" is used by the default formatting. "{:a}" clearly provides a format specifier. If "{}" or "{:s}" was used instead, the default format specifier for floating-point numbers still wouldn't be used, because 255 is not a floating-point number.
User avatar
Ragnar
Posts: 614
Joined: 30 Sep 2013, 15:25

Re: [v2.0.11] Signed hexadecimal double-precision floating-point value

15 Feb 2024, 18:45

I've moved this topic from "Bug Reports" to "Suggestions on Documentation Improvements".
User avatar
Ragnar
Posts: 614
Joined: 30 Sep 2013, 15:25

Re: [v2.0.11] Signed hexadecimal double-precision floating-point value  Topic is solved

07 Mar 2024, 08:52

Thanks for reporting. I've fixed this and some other Format examples.

Return to “Suggestions on Documentation Improvements”

Who is online

Users browsing this forum: No registered users and 60 guests