As I understood from the documentation, AutoHotkey has internal precision 'about' 15 digits and if I don't use SetFormat,FloatFast, the precision should be maintained throughout the whole script. If I use SetFormat,FloatFast and store a value into a variable afterwards, it may result in loss of precision (if less, than 15 decimal places used as the parameter). So I have the following script, which yields different results when using the SetFormat, than when not and I'm wondering why.
Code: Select all
SetFormat,FloatFast,0.16
MsgBox,% Format("{:.16f}",rad2deg2(0.123456789012345)) ;7.0735529626444436 with SetFormat, 7.0735530000000004 without
rad2deg2(a)
{ return b:=a*(180/3.1415926535897932384626433832795) ;Decimals above 15 will be ignored, but shouldn't cause a problem?
}
I don't quite understand how Format() function can replace SetFormat, since the latter one affects the whole rest of the script (until a new thread is started), while Format() only affects how a certain value is presented.