Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Precision in numbers
On 3 Jun 1997 01:02:16 GMT, "Bruce Murphy" <murphbd_at_infinet.com> wrote:
>I work for a research lab where precision is very important. I was asked
>today to allow for a numeric field to be able to allow different precision
>to be held and not be changed by the database. For example:
>
>3.12 would be added for a sample.
>3.124 would be added for another sample
>
>The user (engineers) does not want the precision to be lost. If the field
>is defined as a double or float with four decimal places the numbers are
>stored as:
>
>3.1200
>3.1240
>
>How can one get the precision to be maintained for both reporting and
>calculations? Thanks for any help!
>
If you use the Oracle datatype NUMBER you will get 38 digits of precision. 3.12 will always be 3.12, 3.124 will be 3.124, 1234567890123456789012345.1234567890123456789012345 will always be that number.
If you select such a number out and put it into a native 'float', 'int', 'long', 'double' in a host program, you will probably loose some of that precision.
If you do all your math in pl/sql, select numbers into character strings only, you will get 38 digits of precision with no lose. the second you move it into a float/double/int/long, you may (will) loose precision (especially with floats/doubles as they support 10-13 digits of precision and can't represent all numbers).
>One thought we had was to use a text field and then use the conversion to
>number, but I don't like this approach.
>
>
>Bruce Murphy
Thomas Kyte
tkyte_at_us.oracle.com
Oracle Government
Bethesda MD
http://govt.us.oracle.com/ -- downloadable utilities