0% found this document useful (0 votes)
23 views

Floating-Point Numbers: Chapter 1: Creating

1. Floating-point numbers like REAL, DOUBLE, and FLOAT store approximate values and are subject to rounding errors, unlike exact decimals. 2. REAL and FLOAT(1) to FLOAT(24) use single precision with 24 bits and roughly 6 decimal places. DOUBLE and FLOAT(25) to FLOAT(53) use double precision with 53 bits and 15 decimal places. 3. The valid value ranges are larger for floating-point numbers than exact decimals, making them useful for scientific calculations, but not suitable for exact values.

Uploaded by

Nishki Gejmer
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views

Floating-Point Numbers: Chapter 1: Creating

1. Floating-point numbers like REAL, DOUBLE, and FLOAT store approximate values and are subject to rounding errors, unlike exact decimals. 2. REAL and FLOAT(1) to FLOAT(24) use single precision with 24 bits and roughly 6 decimal places. DOUBLE and FLOAT(25) to FLOAT(53) use double precision with 53 bits and 15 decimal places. 3. The valid value ranges are larger for floating-point numbers than exact decimals, making them useful for scientific calculations, but not suitable for exact values.

Uploaded by

Nishki Gejmer
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Chapter 1: Creating 11

If both the precision and scale are omitted, the default is ( 30, 6 ). If the preci-
sion is specified but the scale is omitted, the scale defaults to zero. If both the
precision and scale are specified, the scale must be in the range 0 <= scale <=
precision. In other words, the decimal point cannot be shifted away from the
actual digits of precision.
The storage requirements depend on the precision and scale of the actual
values stored, not the declared precision and scale. For example, 123456789
will take more storage than 123, and 1.123456789 will take more disk space
than 1.1. The formula for the bytes required is:
2 + TRUNCNUM ( ( p - s + 1 ) / 2, 0 ) + TRUNCNUM ( ( s + 1 ) / 2, 0 )
where p and s are the actual precision and scale after any leading and trailing
zeroes are ignored.

1.5.4 Floating-Point Numbers


Floating-point numbers have far larger ranges than exact decimals so they are
useful in scientific calculations where a minimum precision is required regard-
less of how large or small the values are. However, they are not suitable for
exact calculations because they are subject to rounding errors. In particular, two
different calculations that are supposed to yield the same result may in fact give
slightly different answers when floating-point numbers are used.
The REAL, DOUBLE, and FLOAT data types are implemented as single-
and double-precision approximate floating-point binary numbers.
<float_numeric_type> ::= REAL
| DOUBLE [ PRECISION ]
| FLOAT "(" <single_precision> ")"
| FLOAT "(" <double_precision> ")"
| FLOAT
<single_precision> ::= integer literal in the range 1 to 24
<double_precision> ::= integer literal in the range 25 to 53
REAL is stored in exactly the same manner as FLOAT ( 24 ), and so are all the
declarations from FLOAT ( 1 ) through FLOAT ( 23 ): a single-precision num-
ber with 24 binary digits of precision, which is roughly equivalent to six
decimal digits. REAL values always require 4 bytes of storage and can have
positive and negative values with absolute values ranging from 1.175495e38 to
3.402823e+38. Values may appear to have more than six decimal digits of preci-
sion but they are subject to round-off error after the sixth digit.
DOUBLE is the same as FLOAT ( 53 ), and so are FLOAT ( 25 ) through
FLOAT ( 52 ): a double-precision number holding 53 bits of precision or 15
decimal digits. DOUBLE values always need 8 bytes and can have positive and
negative values with absolute values ranging from 2.22507385850721e308 to
1.79769313486231e+308. Values are subject to round-off error after the 15th
digit.
If FLOAT is specified without a precision, REAL is assumed. You can set
the FLOAT_AS_DOUBLE option to 'ON' to change this assumption to be
DOUBLE.

You might also like