|
Boost : |
From: Mathias Gaunard (mathias.gaunard_at_[hidden])
Date: 2008-06-09 08:31:11
Mårten Rånge wrote:
> 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.
Isn't simply using integers enough?
> 1
> -0.2
> -0.2
> -0.2
> -0.2
> -0.2
1 = 10 / 10
-0.2 = 2 / 10
-0.2 = 2 / 10
-0.2 = 2 / 10
-0.2 = 2 / 10
-0.2 = 2 / 10
= 0 / 10 = 0
and now you have no problem.
Just store an integer and how many times it has been multiplied by 10
compared to the real value.
Then when doing an operation make sure that number is the same for both.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk