Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Decimal arithmetics in C or C++?

The IEEE-754 norm define decimal arithmetics in order to avoid rounding errors when using base-ten floating point numbers (see for example decimal64 on wikipedia). Is there a way to use this decimal arithmetics in C or C++?

like image 562
Cathy Avatar asked Oct 03 '22 14:10

Cathy


1 Answers

TR 24733 specifies decimal floating-point math for C++, based on IEEE-754. The TR means that it's a technical report, so it's not part of the C++ standard. GCC says they have a partial implementation. There is currently a proposal in the works to add it to the C++ standard, but that's several years away at best.

like image 100
Pete Becker Avatar answered Oct 07 '22 19:10

Pete Becker