Re: Pro*C and High precision NUMBER datatype?

From: Jim Morgan <jjmorgan_at_us.ibm.com>
Date: 1998/08/31
Message-ID: <6semau$1igq$1_at_rtpnews.raleigh.ibm.com>#1/1


I'd be careful about using long doubles in C. With floating point numbers there are gaps as to which numbers can be represented. We ran into this same problem (decimal 18 columns) and ran some test cases to prove the gaps exist.

The only way I can see to solve the problem (this worked fine for us) is to represent numbers that are that big as character in the database. In our case that was ok since we never did math on those numbers (they were things like an account number). If you need to do math on those columns, you've got a bigger problem.

Assuming you need those columns to be numeric, my suggestion would be to always use character host variables when working with those columns (for selects, inserts, updates). Whenever you need to do some math on the column, let the database do it (e.g. UPDATE table SET Column1 = Column1 + 50) instead of selecting the column into a host variable, manipulating the host variable and updating the database directly from the host variable. I realize you application may be such that restricting math like this may be difficult or impossible...

It also may depend on what platform your code will run on. For instance, I think what you really need is a long long (64-bit) but the implementation of a long long is not ANSI so you are not guaranteed it will be any bigger than a double.

--
Regards,
Jim
Raymond Li wrote in message <35E978F3.1584B0E2_at_planet.net.hk>...

|Hello,
| It seems that Pro*C only support double datatype, which guarantee
|only about 15 decimal digits of precision, but not long double. However,
|we need to store (and calculate) monetary figures with precision up to
|18 or 20 decimal digits. What possible solutions are there to process
|precision higher than 15 decimal digits?
|
| The obvious solution we can devise is to use long double in C, while
|convert to varchar when interfaced with the Database.
|
| Can someone share there experience and opinion for processing Oracle
|NUMBER datatype with high precision ( more than 15 or 16 decimal digits
|).
|
| Thanks in advance for your advices. Please cc your reply to my
|mailbox as well!
|
| Regards,
| Raymond Li
|
Received on Mon Aug 31 1998 - 00:00:00 CEST

Original text of this message