Current location - Training Enrollment Network - Mathematics courses - How is floating-point data stored in a computer?
How is floating-point data stored in a computer?
For floating-point data, single-precision type (float) and double-precision type (double) are used for storage, in which float data takes up 32 bits and double data takes up 64 bits.

Single precision and double precision are divided into three parts in storage:

1, symbol): 0 means positive, 1 means negative.

2. Index: used to store the index data in the scientific counting method, and shift storage is adopted.

3. mantissa: mantissa.

Extended data

Real variables are divided into single precision and double precision.

Its type descriptor is floating-point single-precision descriptor, double-precision.

Double precision specifier. turbocharge

Single-precision type C occupies 4 bytes (32 bits) of memory space, and the range of values is 3.4e-38 ~ 3.4e+38, and only 7 significant digits can be provided.

Double precision type accounts for 8

Bytes (64 bits) of memory space, its numerical range is1.7e-308 ~1.7e+308, which can provide 16 significant digits.

The format and writing rules of real variable description are the same as those of integers.

For example: float x, y; (x, y are single-precision real numbers)

Double a, b, c; (A, B and C are double-precision real quantities)

Real constants, whether single precision or double precision, are regarded as double precision and double type.

Baidu encyclopedia-floating point data