v1 by default truncated floating-point values
when converted to a string, and that doesn't seem to have caused much confusion. Basically the only difference now is that format() will be used to override the default instead of SetFormat. 6 digits is the same precision that
printf uses by default.
How will leaving the default behaviour the same as v1 cause confusion "during the switch"? I think the opposite would be true.
Zelio wrote:By default, it is not better to have always a full precision or full precision with a zero auto-trim at right ?
The thing is: floating-point numbers aren't precise. For instance:
Code: Select all
f1 := 0.10 + 0.20
f2 := 0.30
MsgBox % f1=f2 ? "equal" : "not equal" ; displays "not equal"
MsgBox % format("{1:0.17g}", f1) ; displays 0.30000000000000004
Notice that 'g' truncates trailing 0s, but it also produces scientific notation in some cases. For example, 0.00001 with 0.15g produces 1e-005, but apparently that's not really full precision; with 0.17g it produces 1.0000000000000001e-005.
Zelio wrote:By default, it is not better to have always a full precision or full precision with a zero auto-trim at right ?
Just because I like to twist words: AutoHotkey uses
double-precision floating point numbers, so by displaying half you actually get full precision.
a complicated non-built-in Format() who merge string/number/type
Who's going to be using floating-point numbers with that precision that would be confused by format()? (I don't know the answer; I've never needed such precision in AutoHotkey.) That it's not built-in is irrelevant for two reasons: 1) usage is the same regardless; 2) it'll be built in. Furthermore, the main complexity is in understanding the format specifiers; but SetFormat uses those same "complicated" specifiers.
Anyway, good point about Round().
just me wrote:V2 doesn't have a SetFormat command any more, but is keeping the v1.1 default precision for floating-point output instead of working with full precision.
Not for floating-point output, but for string output of floating-point numbers. The difference is important.
One other important thing: Prior to v1.0.48+ and in any v1.x version with
SetFormat Float (not FloatFast), simply storing a floating-point number in a variable caused it to lose precision.