Pro*C rounding problem on SUN

From: Mike Culberson <culberso_at_tybrin.com>
Date: Wed, 30 Nov 1994 21:15:12 GMT
Message-ID: <1994Nov30.211512.14722_at_tybrin.com>


I am working on a SUN 630MP with Oracle 7.1.4.1.0, Pro*C 2.0.4.0.0, and SunOS 4.1.3_U1. 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

code


#include <stdio.h>

EXEC SQL BEGIN DECLARE SECTION;

	double value;
	char   oracleid = '/';

EXEC SQL END DECLARE SECTION; EXEC SQL INCLUDE sqlca;

main ()
{

        EXEC SQL CONNECT oracleid;

	EXEC SQL SELECT val 
                 INTO   :value
	         FROM   oracle_table;

	printf ("value = %15.30g\n",value);

}

If val is 1.55 the value printed out would be 1.55000000000000004440892098501 Since I am dealing with multipling rates and calculating totals this causes my totals to be off. So far the only way to ensure correct calculations are to make all numbers integer within the Pro*C program. Are there any math libraries out there that would solve the problem.

                        Thanks Mike

Mike Culberson
culberso_at_tybj3.eglin.af.mil or 129.61.180.1 Received on Wed Nov 30 1994 - 22:15:12 CET

Original text of this message