Hacker News new | ask | show | jobs
by shawnhermans 4336 days ago
Maybe I am wrong, but is the author just looking for a decimal type? Those exist in most major languages, right?
2 comments

Decimal types suffer from many of the same issues.

Sure, 0.1 can be represented exactly. But that's about the only issue with floating-point that that solves.

The performance of decimal arithmetic on hardware not recently made by IBM means it cannot be used in most places.
The original post said he'd be happy to trade performance for consistency.

He could also use fdlibm ( http://netlib.org/fdlibm/index.html ), at least for anything other than primitive operations. But, again, it trades performance for consistency.

This week I learned that C99 and C11 have an FP_CONTRACT pragma, that can be set "off" for this reason ( http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf , section 6.5, paragraph 8).