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: FLOAT data type. Range ?

Re: FLOAT data type. Range ?

From: Michel Cadot <micadot_at_netcourrier.com>
Date: Mon, 23 Aug 1999 18:37:43 +0200
Message-ID: <7prtdt$46c$1@oceanite.cybercable.fr>


Here's a complete Oracle Documentation on Number

NUMBER Datatype
The NUMBER datatype is used to store zero, positive and negative fixed and floating point numbers with magnitudes between 1.0 x 10^-130 and 9.9...9 x 10^125 (38 9s followed by 88 0s) with 38 digits of precision. If you specify an arithmetic expression whose value has a magnitude greater than or equal to 1.0 x 10^126, Oracle7 returns an error.
You can specify a fixed point number using the following form:

NUMBER(p,s)
where:

p

is the precision, or the total number of digits. Oracle7 guarantees the portability of numbers with precision ranging from 1 to 38.

s

is the scale, or the number of digits to the right of the decimal point. The scale can range from -84 to 127.

You specify an integer using the following form:

NUMBER(p)

is a fixed point number with precision p and scale 0. (Equivalent to NUMBER(p,0).)

You specify a floating point number using the following form:

NUMBER is a floating point number with precision 38. Note that a scale value is not applicable for floating point numbers.

Scale and Precision
Specify the scale and precision of a fixed point number column for extra integrity checking on input. Specifying scale and precision does not force all values to a fixed length. If a value exceeds the precision, Oracle7 returns an error. If a value exceeds the scale, Oracle7 rounds it. The following examples show how Oracle7 stores data using different precisions and scales.

Actual Data Specified As Stored As

7456123.89   NUMBER        7456123.89
7456123.89   NUMBER(9)     7456124
7456123.89   NUMBER(9,2)   7456123.89
7456123.89   NUMBER(9,1)   7456123.9
7456123.8    NUMBER(6)     exceeds precision
7456123.8    NUMBER(15,1)  7456123.8
7456123.89   NUMBER(7,-2)  7456100
7456123.89   NUMBER(-7,2)  exceeds precision



Negative Scale
If the scale is negative, the actual data is rounded to the specified number of places to the left of the decimal point. For example, a specification of (10,-2) means to round to hundreds.

Scale Greater than Precision
You can specify a scale that is greater than precision, although it is uncommon. In this case, the precision specifies the maximum number of digits to the right of the decimal point. As with all number datatypes, if the value exceeds the precision, Oracle7 returns an error message. If the value exceeds the scale, Oracle7 rounds the value. For example, a column defined as NUMBER(4,5) requires a zero for the first digit after the decimal point and rounds all values past the fifth digit after the decimal point. The following examples show the effects of a scale greater than precision:

Actual Data Specified As Stored As

.01234       NUMBER(4,5)   .01234
.00012       NUMBER(4,5)   .00012
.000127      NUMBER(4,5)   .00013
.0000012     NUMBER(2,7)   .0000012
.00000123    NUMBER(2,7)   .0000012



Floating Point Numbers
Oracle7 also allows you to specify floating point numbers. A floating point value either can have a decimal point anywhere from the first to the last digit or can omit the decimal point altogether. A scale value is not applicable to floating point numbers because there is no restriction on the number of digits that can appear after the decimal point. You can specify floating point numbers with the appropriate forms of the NUMBER datatype discussed in the section "NUMBER Datatype" . Oracle7 also supports the ANSI datatype FLOAT. You can specify this datatype using one of these syntactic forms:

FLOAT specifies a floating point number with decimal precision 38, or a binary precision of 126.

FLOAT(b)

specifies a floating point number with binary precision b. The precision b can range from 1 to 126.

To convert from binary to decimal precision, multiply b by 0.30103. To convert from decimal to binary precision, multiply the decimal precision by 3.32193. The maximum of 126 digits of binary precision is roughly equivalent to 38 digits of decimal precision.

rock_cogar_at_my-deja.com a écrit dans le message <7prp4l$6cj$1_at_nnrp1.deja.com>...
>I have a really simple question that I cannot find in my limited Oracle
>Documentation.
>
>What is the range of the Oracle data type FLOAT ?
>
>I expect it is something like -1x10^8 to +1x10^8
>
>Thanks,
>Rock Cogar.
>
>
>Sent via Deja.com http://www.deja.com/
>Share what you know. Learn what you don't.
Received on Mon Aug 23 1999 - 11:37:43 CDT

Original text of this message

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