Solved

Looking for BCD source code

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

Thanks for your help

0
Comment
Question by:bhasnier
  • 2
  • 2
5 Comments
 
LVL 6

Expert Comment

by:Triskelion
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

by:bhasnier
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

by:imladris
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

by:bhasnier
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

by:
imladris earned 100 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

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.

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

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

Join & Ask a Question