Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - Examples of correct representation of floating point numbers
Examples of correct representation of floating point numbers

The correct representation of floating-point numbers is as follows:

1. 3.14 is a decimal floating-point number with a mantissa of 3.14 and an exponent of 0. It can be written as 3.14e0 or 3.14E0.

2. 0.00123 is a decimal floating point number with a mantissa of 1.23 and an exponent of -3. It can be written as 1.23e-3 or 1.23E-3.

3. 1.5e10 is a decimal floating point number with a mantissa of 1.5 and an exponent of 10. It can be written as 1.5e10 or 1.5E10.

Data expansion:

Floating point representation is known to be performed by C/C++ compilers in accordance with the IEEE floating point representation formulated by IEEE (International Institute of Electrical and Electronic Engineers) operational. This structure is a scientific notation represented by a sign (+ or -), an exponent and a mantissa, with the base being determined to be 2. So in IEEE floating-point number representation, a floating-point number is the mantissa multiplied by 2 raised to the power plus the sign.

Introduction:

The float specification float is 32 bits in total, and the 4 bytes from the highest to the lowest are the 31st, 30th, 29th,..., and 0th bits, then : Bit 31 is the sign bit, 1 means the number is negative, 0 means positive. Bits 30-23, 1 to 8 are the exponent bits. Bits 22-0, and bits 23 to 23 are the mantissa bits. 3. Conversion example: Convert float type floating point number 123456.0f into binary according to IEEE floating point number representation.

When dealing with floating point numbers without decimals, directly convert the integer part into binary representation: 11110001001000000 can also be expressed like this: 11110001001000000.0 and then move the decimal point to the left until it is only 1 place away from the highest position: 1.11100010010000000 *** Shifted 16 bits to the left, so the original number is equal to: 1.11100010010000000*(2^16). It can be seen that the mantissa is 1.