Re: Pro*C rounding problem on SUN

From: Denzer_Volker <ddt_at_dsapp1.hmi.de>
Date: 15 Dec 1994 16:15:30 +0100
Message-ID: <3cpmii$q31_at_dsapp1.hmi.de>


Hi,
culberso_at_tybrin.com (Mike Culberson) writes:

> The problem I am having is when I fetch a NUMBER column from
>a table the value referenced in the host variable is not the exact
>number value in table. I am working with an accounting system and numbers
>need to be exact. Example of code follows.

>oracle_table
>val NUMBER(11,2) with a value of 1.55
 

> EXEC SQL SELECT val
> INTO :value
> FROM oracle_table;
 

>If val is 1.55 the value printed out would be 1.55000000000000004440892098501

Question: Have you ever counted the number of correct digits in your number ?
You probably haven't. Otherwise you would have noticed that there are more than 14 correct digits. On nearly all machines with 32 bit architecture a double-length number can hold at most 14 decimal digits. Conclusion: The number printed on your screen IS CORRECT (as correct as any computer can store it internally).

>Since I am dealing with multipling rates and calculating totals this causes
>my totals to be off.

... if you can't round 'em.

>So far the only way to ensure correct calculations are
>to make all numbers integer within the Pro*C program.

yep.

>Are there any math
>libraries out there that would solve the problem.

not as far as I know, since this is not a problem of PRO*C nor of the math lib. It's a general problem of storing data in a computer.

> Thanks Mike

I know, my answer won't help avoiding the problem, but

   it is as it is.

Osygus. Received on Thu Dec 15 1994 - 16:15:30 CET

Original text of this message