Home >Backend Development >Python Tutorial >How many bytes does float occupy?

How many bytes does float occupy?

coldplay.xixi
coldplay.xixiOriginal
2020-10-28 09:52:5648590browse

The float type occupies 4 bytes of memory, representing decimals. The data range is between [-2^128 ~ 2^128] [-3.40E 38 ~ 3.40E 38]; the float data type is used to store single Precision floating point number or double precision floating point number.

How many bytes does float occupy?

The float type occupies 4 bytes of memory, represents a decimal, and the data range is -2^128 ~ 2^128 (-3.40E 38 ~ 3.40E 38) between.

The int type occupies 4 bytes of memory, represents an integer, and the data range is between -2^31~2^31-1(-2147483648~2147483647).

The char type occupies 1 byte of memory, representing characters, and the data range is between -2^7~2^7-1(-128 ~127).

How many bytes does float occupy?

Extended information:

The float data type is used to store single-precision floating-point numbers or double-precision floating-point numbers. Floating point numbers use the IEEE (Institute of Electrical and Electronics Engineers) format. The single-precision value of the floating point type includes four parts: number sign, mantissa, exponent sign, and exponent. Since the high-order bit of the mantissa is always 1, it is not stored as a number.

Float data is expressed in exponential form in the machine. The number symbol occupies 1 binary digit, indicating the positive and negative of the number. The exponent sign occupies 1 binary digit and represents the positive or negative exponent. The mantissa represents the valid digits of the floating point number, 0.xxxxxxx, but the leading 0 and dot are not stored. How many digits the exponent occupies and how many digits the mantissa occupies are determined by the computer system.

Related free learning recommendations: python tutorial(Video)

The above is the detailed content of How many bytes does float occupy?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn