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

What is the scope of float

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

This article is to share with you about the scope of float, the editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article.

The float range is "- 3.4E+38 ~ 3.4E+38". The FLOAT data type is used to store single-precision or double-precision floating-point numbers; floating-point numbers use IEEE format. A single-precision value of a floating-point type has 4 bytes, including a symbol bit, an 8-bit binary index, and a 23-bit Mantissa.

1. Float: the number of bits is 32, the significant number is 6-7, and the range of values is-3.4E+38 ~ 3.4E+38

2. Double: 64 bits, 15-16 significant numbers, and the range of values is-1.7E-308~1.7E+308

Floating-point variables can be declared as float or double depending on the needs of the application. The main difference between the two types is the cardinality they can represent, the storage they need, and their range.

Extended data

Two types of floating point type

1. Single-precision floating point (float)

Single-precision floating-point (float) refers specifically to single-precision (single-precision) values that take up 32 bits of storage space. Single precision is faster than double precision on some processors and takes up only half the space of double precision, but when the value is very large or very small, it will become inaccurate. Single-precision floating-point variables are useful when you need a decimal part and do not require high precision.

Floating-point data type, FLOAT data type is used to store single-precision 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 binary index, and a 23-bit Mantissa. 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.

For example, a single-precision floating point type is useful when representing dollars and cents.

Here are some examples of declaring single-precision floating-point variables: float hightemp,lowtemp

2. Double precision (double) floating point type

Double precision, as its keyword "double" indicates, takes up 64 bits of storage space. In some modern processors optimized for high-speed mathematical calculations, double-precision is actually faster than single-precision.

All mathematical functions beyond human experience, such as sin (), cos (), tan (), and sqrt (), return double-precision values. Double precision is the best choice when you need to maintain the accuracy of repeated iterations, or when manipulating numbers with large values.

The above is the scope of float, the editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

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