Fixed- and Floating-Point Data Types
Fixed- and Floating-Point Data Types
number: precision
10.523 5
precision
refers to the number of digits in a number
Fixed- and Floating-Point Data Types
number: precision scale
10.523 5 3
scale
refers to the number of digits to the right of the decimal point in a
number
Fixed- and Floating-Point Data Types
number: precision scale
10.523 5 3
36.875 5 3
e.g. DECIMAL ( 5 , 3 )
Fixed- and Floating-Point Data Types
text ≠ numbers
numeric data types
integer fixed-point floating-point
Fixed- and Floating-Point Data Types
fixed-point data represent exact values
DECIMAL ( 5 , 3 ) 10.523
10.5 10.500
10.5236789 10.524
Fixed- and Floating-Point Data Types
fixed-point data represent exact values
when only one digit is specified within the parentheses, it will be
treated as the precision of the data type
DECIMAL ( 7 )
1234567
DECIMAL ( 7, 0 )
Fixed- and Floating-Point Data Types
fixed-point data represent exact values
DECIMAL has a synonymous data type. It is called NUMERIC.
DECIMAL = NUMERIC
Fixed- and Floating-Point Data Types
text ≠ numbers
numeric data types
integer fixed-point floating-point
INTEGER DECIMAL
NUMERIC
Fixed- and Floating-Point Data Types
DECIMAL = NUMERIC
e.g. salaries
NUMERIC ( p , s )
precision: p = 7
scale: s = 2
e.g. NUMERIC (7,2) $ 75,000.50
Fixed- and Floating-Point Data Types
floating-point data type
- used for approximate values only
- aims to balance between range and precision ( => “floating” )
FLOAT ( 5 , 3 ) 10.523
10.5236789 10.524
(10.524 is an approximate value)
Fixed- and Floating-Point Data Types
the main difference between the fixed- and the floating-point type
is in the way the value is represented in the memory of the computer
DECIMAL ( 5 , 3 )
10.5236789 10.524
FLOAT ( 5 , 3 )
10.5236789 10.524
Fixed- and Floating-Point Data Types
text ≠ numbers
numeric data types
integer fixed-point floating-point
INTEGER DECIMAL FLOAT
NUMERIC DOUBLE
Fixed- and Floating-Point Data Types
Floating-point size precision maximum number
data type (bytes) of digits
FLOAT 4 single 23
DOUBLE 8 double 53