Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Is the type of 3.14 float or flexible?

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

Today, I will talk to you about whether the type of 3.14 is float or flexible. Many people may not know much about it. In order to make you understand better, the editor has summarized the following content for you. I hope you can get something according to this article.

3.14 is a simple type. Because the representation of the middle number of 3.14 in the computer can not be accurately described, it is generally only an approximate value, so "3.14f" can be expressed as float type, while 3.14 can only be expressed as float type.

3.14 is a flexible type.

1. The double data type is similar to the single precision data type (float), but it is more accurate than float, and the memory space occupied at compile time varies with different compilers.

Typically, single-precision floating-point numbers take up 4 bytes (32 bits) of memory and their values range from-3.4E38 to 3.4E38, while double-precision accounts for 8 bytes (64 bits) of memory and their values range from-1.7E308~1.7E+308.

3.14 the representation of decimal numbers in computers is basically impossible to describe accurately, and it is generally just an approximate value (except for special cases such as 0.5), which is why we cannot use = = to compare floating point numbers. instead, the difference between two numbers is used to show that the two numbers are equal in a very small range.

So 3.14f can be expressed as float, while 3.14 can only be expressed as float.

2. Declare a variable of type double: double puotient; initializes a variable of type double: puotient = 5.621456873bot double puotinet = 5.62.

3. Float is generally 4 bytes, double is generally 8 bytes, and the range is larger than float.

Expansion materials:

1. In C language, double precision floating point (double) type occupies 8 bytes (64 bits) of memory space. Its numerical range is-1.7E308~1.7E+308, the double precision fully guaranteed effective number is 15 digits, 16 digits are only partially guaranteed, while the single precision guarantees 7 significant digits, and some values have 8 significant digits.

In a narrow sense, floating point is scientific notation, double precision, that is, double. Double means two or two.

2. C standard requires the precision of float type to be 7 bits, and the representation range of integer parts should be at least-1.0E37-- 1.0E+37. Float is generally 32-bit.

The C standard specifies that the minimum representation range of the integer portion of the double type is the same as that of float, from-1.0E37 to 1.0E+37, but it requires a precision of 15 to 16 bits for the double type. Double is usually 64-bit. The controller of the output double float type is lf. When a variable is defined, it can be abbreviated to double.

3. Floating-point data type. FLOAT data type is used to store single-precision floating-point numbers or double-precision floating-point numbers.

Floating point numbers use the IEEE (Society of Electrical and Electronic Engineers) format. A single-precision value of a floating-point type has 4 bytes, including a symbol bit, an 8-bit excess-127 binary index, and a 23-bit Mantissa. The Mantissa represents a number between 1.0 and 2.0.

Because the high order bit of the Mantissa is always 1, it is not stored in digital form. This representation provides a range of roughly between-3.4E-38 and 3.4E+38 for float types.

After reading the above, do you have any further understanding of whether the type of 3.14 is float or flexible? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report