Join Nostr
2025-12-31 04:24:59 UTC
in reply to

Jean-Francois Mezei on Nostr: This is why banking apps use integer variables and math supported by COBOL: 01 ...

This is why banking apps use integer variables and math supported by COBOL:

01 MY-BALANCE PIC S9(6)V9(2) USAGE COMP3.

"Comp3" directs creation of a packed decimal data type ( integer).

the floating point internal representation in computers is imprecise. (lookup IEEE 754).

You can can fun entering various floating point numbers at this page:
https://www.h-schmidt.net/FloatConverter/IEEE754.html

(enter number on the "Decimal representation" and see how it gets converted and the resulting error. (some numbers such as 5.25 convert cleanly, but 5.24 won't).