Go Premium for a chance to win a PS4. Enter to Win

x
Solved

# Looking for BCD source code

Posted on 2001-09-17
Medium Priority
346 Views
Last Modified: 2008-01-09
I'am looking for a BCD math library in C.
I just need +,-,*,/.

Thanks for your help

0
Question by:bhasnier
• 2
• 2
5 Comments

LVL 6

Expert Comment

ID: 6489246
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

Author Comment

ID: 6489538
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

LVL 16

Expert Comment

ID: 6490792
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

Author Comment

ID: 6491019
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

LVL 16

Accepted Solution

imladris earned 300 total points
ID: 6491372
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

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.
###### Suggested Courses
Course of the Month8 days, 10 hours left to enroll

#### 877 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.