Solved

Looking for BCD source code

Posted on 2001-09-17
5
341 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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 switch statements in the C programming language.

717 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