Current location - Loan Platform Complete Network - Big data management - What are the effective digits and precision of float and double in C?
What are the effective digits and precision of float and double in C?

Float has 6 - 7 effective digits, 4 bytes, 8 bits of exponent length, and 23 bits of decimal length. The range of values is ?3.4E-38 to 3.4E+38.

Double has 15 - 16 significant digits, a byte count of 8, an exponent length of 11 bits, and a decimal length of 52 bits. The range of values is 1.7E-308 to 1.7E+308.

Extended Information

Variables can be declared as float or double, depending on the needs of the application.The main differences between the two types are the number of bases that they can represent, the storage that they require, and their range. If storage is more important than precision, use the float type for floating-point variables. Conversely, if precision is the most important requirement, use the double type.

Floating-point variables can be promoted to types with larger bases (from float to double). Lifting usually occurs when you perform arithmetic on a floating-point variable. This arithmetic is always performed with as much precision as the variable with the highest precision.

Baidu Encyclopedia - Floating-point data