Bug 47003

GemStone/S 64 Bit

3.6.1, 3.6, 3.5.7, 3.5.6, 3.5.5, 3.5.4, 3.5.3, 3.5.2, 3.5.1, 3.5, 3.4.5, 3.4.4, 3.4.3, 3.4.2, 3.4.1, 3.4, 3.3.9, 3.3.8, 3.3.7, 3.3.6, 3.3.5, 3.3.4, 3.3.3, 3.3.2, 3.3.1, 3.3

Floating point printing may include unnecessary trailing digits

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

Workaround

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