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

Fixed - and Floating-Point Data Types

The document discusses fixed-point and floating-point numeric data types. Fixed-point types like DECIMAL/NUMERIC store values exactly, while floating-point types like FLOAT aim to balance precision and range by storing approximate values. Precision refers to the total number of digits, and scale refers to digits after the decimal. For example, DECIMAL(5,3) would have 5 digits total and 3 after the decimal.

Uploaded by

Nishant Randev
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)
66 views

Fixed - and Floating-Point Data Types

The document discusses fixed-point and floating-point numeric data types. Fixed-point types like DECIMAL/NUMERIC store values exactly, while floating-point types like FLOAT aim to balance precision and range by storing approximate values. Precision refers to the total number of digits, and scale refers to digits after the decimal. For example, DECIMAL(5,3) would have 5 digits total and 3 after the decimal.

Uploaded by

Nishant Randev
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/ 14

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

You might also like