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

Home -> Community -> Usenet -> c.d.o.tools -> Re: Problem with Oracle rounding integers

Re: Problem with Oracle rounding integers

From: chasbas <chasbas_at_aol.com>
Date: 2000/07/15
Message-ID: <hB1c5.185$aO1.2502@news3.voicenet.com>#1/1

I have a library of routine that do calculations. In porting it to PL/SQL, I find that I have lots of code that looks like this:

   X := 1;
   Y := 2;
   I := X / Y * 2;

In every other language I know (C, FORTRAN, Perl, FoxPro, etc.), this results in I being zero (although Pascal contains a special integer division symbol). In PL/SQL, however, it rounds X / Y up to 1 and I becomes 2. Since this behavior is unlike any other language, my code does not already contain FLOOR (or TRUNC) around integer divides. I have written a program to automatically convert my code to PL/SQL, but it cannot accurately figure out whether a particular division is supposed to be floating point or integer, so I can't automatically add TRUNC around all the integer divisions.

So, my question is, is there any facility in PL/SQL for *not* rounding an integer divide. I have read in a book that PLS_INTEGERs do not round, but that seems not to be true. I have also read that NUMBERs without a scale (the second parameter) will not be rounded - this is not true either. Is there any way anyone knows to avoid this rounding problem, or do I have to manually go through 1000 routines looking for integer divides and adding calls to TRUNC around them (a very error laden process!)?

Thanks Received on Sat Jul 15 2000 - 00:00:00 CDT

Original text of this message

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