Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - What is the difference between integer and real in C language?
What is the difference between integer and real in C language?
The most important difference between integer and real number in C language is the coding method.

1, integers are generally encoded in three ways: original code, complement and complement.

Original code: the first bit represents the symbol, and the remaining bits represent the value. For example, if it is an 8-bit binary:

The left most significant bit of the original code1= 0000001/is the sign bit, and 0 represents a positive number.

Original code-1 =1000001/leftmost highest bit1stands for negative number.

Anti-code: that is, on the basis of the original code, the sign bit remains unchanged and other bits are inverted.

The complement of-1 =11111/Note that the sign bit remains unchanged.

Complement: add 1 on the basis of complement.

The complement of-1 is =11111.

2. Real number types usually use IEEE754 coding method. In IEEE754, the sign bit, exponent bit and mantissa bit of real numbers are specified, that is, the number of binary digits occupied by significant bits, as follows:

Format length sign bit exponent bit mantissa bit significant digit exponent shift mantissa description

Single precision 32 1 8 23 24 127 has a hidden bit.

Double precision 6411152 531023 has a hidden bit.

The extended double precision 80115646416383 has no hidden bits.

Note: the extended double-precision format has no hidden bits, so its effective digits are the same as the mantissa digits, while both single-precision and double-precision formats have a hidden bit, so its effective digits are more than the mantissa digits 1.