Comment

Comment by kirab

For people using C or C++ I can recommend using decimal floating point (which may be added to C++20 in the standard).

Contrary to the "default" floating point, which are base 2 and do not support precise presentations of certain numbers, you can use a decimal floating point system which uses base 10 and therefore allows exact and precise presentation and solves the problem mentioned on the page.

Also important: since 2008 this is standardized in IEEE 754-2008 which added support for decimals.

Explanation of decimal floating points: https://en.m.wikipedia.org/wiki/Decimal_floating_point

Libraries:

https://software.intel.com/en-us/articles/intel-decimal-floa...

http://www.bytereef.org/mpdecimal/

http://speleotrove.com/decimal/

C++ Standard Proposals:

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n340...

http://open-std.org/JTC1/SC22/WG21/docs/papers/2014/n3871.ht...

parent kirab 9 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton