Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Pro*C problem

Re: Pro*C problem

From: Keith Jamieson <pdkj02_at_email.mot.com>
Date: Tue, 16 Feb 1999 08:06:05 +0000
Message-ID: <36C926ED.F5834258@email.mot.com>


You really need to decide on exactly how accurate your data needs to be.
e.g. Does your data have to be accurate to 2,4, or 6 decimal places. It
is pointless to proceed without at least knowing this information.

Oracle can store floating point numbers to a much greater precision than most floating point implementations, so you should allow for rounding errors.

You start to  lose precision in your rounding function because your field is declared as number 15,6 but you are only rounding to 2 decimal places. You should be using as a minimum select round(varname,6) . This should eliminate most of your rounding errors and enable you to continue using the double datatype.

There is another datatypoe VARNUM which will hold numbers as they are stored in the Oracle Database, but for full representation it must be declared as 22 Bytes long.
 
 

Lori Wang wrote:

I have a Pro*C program that uses data from an oracle
table where the field is defined as number(15,6).  I select
it as round(varname,2) into a variable in C that is declared
as a double.  On down in the program I do some calculations
on the double.  Then I go to print it out.  I print it out with
2 digits past the decimal point as in %8.2f.  The problem
that I'm having is that I need to add up all these numbers of
2 digit precision for a total but I'm using the data that is in
the C double variable that's been calculated on and it is
spitting out a total number that is off by a few thousand's.
What can I use in Pro*C besides double that will give me
2 digits precision?

Thanks in advance,

Lori Wang

  Received on Tue Feb 16 1999 - 02:06:05 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US