Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Actually 128 int uses 2 times the storage for less dynamic range. I agree however that for financial applications int is always better. You don't want float dynamic range on finance calculations
 help



You are right, I forgot that nowadays standard decimal floating-point numbers do not use BCD encoding any more, but they pack 3 decimal digits into each 10 bits.

This means that the 64-bit decimal64 format still provides an acceptable precision of 16 digits, even if it is lower than for 64-bit integers, which provide over 18 digits.

If the goal is to avoid rounding, 64-bit binary integers are still superior to decimal64, due to the availability of more significant digits, but due to its scale factor decimal64 is superior if you want to express a huge amount of money while allowing rounding, which would probably be needed only for amounts greater than the budgets of all countries together.

You are right that decimal64 provides a greater dynamic range than 128-bit binary integers, but even so the dynamic range of 128-bit integers is many orders of magnitude greater than needed for any imaginable amount of money, while providing exact operations performed at a speed many times greater than for decimal64.

On computers without hardware support for the IEEE standard decimal formats, much faster operations with decimal floating-point numbers can be implemented if they are not represented like in the standard, but as a product between a binary integer and an integer power of ten.




Consider applying for YC's Winter 2027 batch! Applications are open till November 2.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: