3.4.Floating Point and Decimal Types

Floating point type is either a float or double. They are used any time you need to represent a real number, as defined by IEEE 754.

Decimal types should be used when representing financial or money values.

The Floating Point and Decimal Types with Size, precision, and Range
Type Size (in bits) precision Range
float 32 7 digits 1.5 x 10-45 to 3.4 x 1038
double 64 15-16 digits 5.0 x 10-324 to 1.7 x 10308
decimal 128 28-29 decimal places 1.0 x 10-28 to 7.9 x 1028

Floating point types are used when you need to perform operations requiring fractional representations. However, for financial calculations, the decimal type is the best choice because you can avoid rounding errors.

Yes No Suggest edit
Suggest Edit