In v3.3, the default printing of floating points was changed from using the format string '%.16E' to using the format string '%.16g', to avoid the string including unnecessary trailing digits (that is, to print optimally). This change unfortunately introduced a bug in missing precision (bug 46855).
It also did not always print optimally. For example, in versions prior to 3.3,
9.44 asString -> 9.4399999999999995E00
9.45 asString -> 9.4499999999999993E00
In 3.3 and later:
9.44 asString -> 9.44
9.45 asString -> 9.449999999999999
While both these printing formats for 9.45 are entirely correct, they are not optimal, since 9.45 has sufficient precision. Each of the following returns the same object, the SmallDouble with OOP 9380547663850006118.
'9.45' asNumber
'9.4499999999999993E00' asNumber
'9.449999999999999' asNumber
As in versions prior to 3.3, printing using asStringUsingFormat: allows you to specify exactly how many decimal places to display, performing decimal rather than floating point rounding.
Last updated: 11/7/17