Reply to post: Good news

Nasdaq's 32-bit code can't handle Berkshire Hathaway's monster share price

Flocke Kroes Silver badge

Good news

Years ago IBM spotted that using binary floating point when scaled integers are required caused problems. They came up with a way of storing numbers internally in decimal instead of binary. You can quickly try it out by firing up python3 and typing:

from decimal import Decimal
Decimal(2) / Decimal(7) == Decimal(1) / Decimal(7) * Decimal(2)
2 / 7 == 1 / 7 * 2
And you get the result False for Decimal and True for binary floating point. It is almost as if using Decimal when you need integers is just as broken as using binary floating point when you need integers. All that work implementing decimal arithmetic and it still does not solve the problem of programmers using floating point where scaled integers are required.

(In python3 int / int -> float. If you want C flavoured division, use the // operator.)

POST COMMENT House rules

Not a member of The Register? Create a new account here.

  • Enter your comment

  • Add an icon

Anonymous cowards cannot choose their icon