• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 348
  • Last Modified:

Looking for BCD source code

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

Thanks for your help

0
bhasnier
Asked:
bhasnier
  • 2
  • 2
1 Solution
 
TriskelionCommented:
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
0
 
bhasnierAuthor Commented:
Thanks, but I need BCD because long or doudle are not accurate enought for my program (simple finance calculs but with lots of digits).
0
 
imladrisCommented:
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.
0
 
bhasnierAuthor Commented:
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.
0
 
imladrisCommented:
OK, if your need is for the support of large numbers, how about using BigNum. This is a collection of C routines that supports arithmetic operations on arbitrarily large numbers. I don't believe it uses BCD perse, but it sounds like it would fulfill your requirement. You can find it in the Portable library at www.snippets.org.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now