|
Boost : |
From: Mårten Rånge (marten.range_at_[hidden])
Date: 2008-06-09 07:20:35
Is there some work been done on implementing a boost::decimal class?
If there isn't my guess is that this would be very useful to C++ programmers
out there if boost could provide this (we sure would dance with joy!). I
would like to help but frankly I lack the competence on how to implement a
decimal class efficiently and with the robustness it needs.
A decimal class would be very useful for ERP and Financial systems as in
many cases of the typical customers work with the decimal system instead of
the binary system. It's hard to motivate for the customers why:
1
-0.2
-0.2
-0.2
-0.2
-0.2
doesn't add up to _exactly_ 0 when using double (windows calc.exe had this
problem many years ago and it attracted lot of gleeful comments, so gleeful
calc.exe uses infinite precision these days to represent rational numbers).
In addition many sums are intended to become 0 at the end (the debit and
credit should be balanced) so cancellation errors like above actually are
quite common.
The key issue is that common numbers such as 0.1, 0.2, and so on can't be
exactly represented in a double.
http://www2.hursley.ibm.com/decimal/
-- Mårten
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk