Solved

Looking for BCD source code

Posted on 2001-09-17
5
339 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

Technology Partners: 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

Suggested Solutions

Title # Comments Views Activity
Coverting 24 hour time to 12 hour in C++ 15 182
How to align numbers in C using the %d 2 111
C++ vs C compilers 13 164
How to jump to matching brace in eclipse editor ? 1 353
Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
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…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.

735 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