Link to home
Start Free TrialLog in
Avatar of bhasnier
bhasnier

asked on

Looking for BCD source code

I'am looking for a BCD math library in C.
I just need +,-,*,/.

Thanks for your help

Avatar of Triskelion
Triskelion
Flag of United States of America image

Well, you could use these macros to covert to decimal, perform the math and convert back to BCD:

http://codeguru.earthweb.com/cgi-bin/bbs/wt/showpost.pl?Board=vc&Number=292958&page=15&view=collapsed&sb=5
Avatar of bhasnier
bhasnier

ASKER

Thanks, but I need BCD because long or doudle are not accurate enought for my program (simple finance calculs but with lots of digits).
A long on a 32 bit machine is 64 bits, which supports numbers up to 18 digits. That's larger than the GDP of any country I can think of. That should be sufficient for any financial calculations.
I working on PDA (some are 16bits).
But 18 digits is not enought, I need numbers like
1 000 000.000  (10 digits). In some calculs I have to multiply two numbers, so I need 20 digits.

I need exact results even the last digits.
ASKER CERTIFIED SOLUTION
Avatar of imladris
imladris
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial