T
tajmorton
Hello,
I've decided to try my hand at writing a decimal class that is suitable
for storing weights, money, and time, etc, because I haven't found a
*decimal* class (yes, I know that boost and gmp have rationals, but
that's not exactly easy to use for money and weights)
I'm storing the number in a signed long int, along with another int
called offset which contains where the decimal point goes. So far I
have implemented addition, subtraction, and multiplication. Those were
easy, but I need some tips on how to do division.
I need to calculate as many decimal places as I can without, without
running out of room in long int. I can store only 10 digits... For
example, 1000/362.33 would need to be rounded to 2.759914995, instead
of 618165760657813034839591637137[...]. Any ideas how to actually
implement this?
Also, I'd like some input on if the way I'm doing this is really the
right way, thoughts?
Thanks!
I've decided to try my hand at writing a decimal class that is suitable
for storing weights, money, and time, etc, because I haven't found a
*decimal* class (yes, I know that boost and gmp have rationals, but
that's not exactly easy to use for money and weights)
I'm storing the number in a signed long int, along with another int
called offset which contains where the decimal point goes. So far I
have implemented addition, subtraction, and multiplication. Those were
easy, but I need some tips on how to do division.
I need to calculate as many decimal places as I can without, without
running out of room in long int. I can store only 10 digits... For
example, 1000/362.33 would need to be rounded to 2.759914995, instead
of 618165760657813034839591637137[...]. Any ideas how to actually
implement this?
Also, I'd like some input on if the way I'm doing this is really the
right way, thoughts?
Thanks!