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

How to find the maximum value in C language

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

Share

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

It is believed that many inexperienced people do not know what to do about how to find the maximum value in C language. therefore, this paper summarizes the causes and solutions of the problem. I hope you can solve this problem through this article.

Everyone should know the minimum and maximum values of integers.

What about floating point numbers? It's a little complicated! And in any interval, the number of floating points is infinite. So the floating point represented in the computer must be jumping.

The maximum value of float (sign 1, index 8, Mantissa 23) is as follows

111111111 the 23 digits of the Mantissa are not all 0, for example, 0xFF800001: is not a numeric value, and NaN is used to represent an invalid value in VxWorks.

1111111000000000000000000000 = 0xFF800000: negative infinity, infinity is represented by Inf in VxWorks

111111110111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111

100000001000000000000000000000 = 0x80800000: represents the largest negative number, that is,-2-126, which is approximately equal to-1.175494mm 10-38, but the precision of printf is limited, so it is generally displayed as 0.

000000000000000000000000000000000000 = 0x00000000: indicates 0

000000001000000000000000000000 = 0x00800000: represents the smallest positive number, that is, 2-126, which is approximately equal to 1.17549410-38

011111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111

0111111000000000000000000000 = 0x7F800000: indicates positive infinity

The 23 digits of the Mantissa of 011111111 are not all 0, for example, 0x7F800001: indicates that it is not a numeric value

The maximum value of double (sign 1, index 11, and Mantissa 52) is as follows

The 52 digits of the Mantissa of 1111111111 are not all 0, for example, 0xFFF0000000000001: indicates that it is not a numeric value

The 52 digits of 111111111111 Mantissa are all 0 = 0xFFF0000000000000: indicates negative infinity

The 52 digits of the Mantissa of 1111111110 are all 1 = 0xFFEFFFFFFFFFFFFF: indicates the smallest negative number, that is,-21024, which is approximately equal to-1.797693mm 10308

The 52 digits of the Mantissa 1000000001 are all 0 = 0x8010000000000000: indicates the largest negative number, that is,-2-1022, which is approximately equal to-2.225074-10-308

The 52 digits of 000000000000 Mantissa are all 0 = 0x0000000000000000: indicates 0

The 52 digits of the Mantissa 00000001 are all 0 = 0x0010000000000000: the smallest positive number, that is, 2-1022, which is about 2.225074-10-308.

The 52 digits of the Mantissa 0111111110 are all 1 = 0x7FEFFFFFFFFFFFFF: indicates the largest positive number, that is, 21024, which is about 1.797693 / 10308.

The 52 digits of the Mantissa 0111111111 are all 0 = 0x7FF0000000000000: indicates positive infinity

The 52 digits of the Mantissa of 0111111111 are not all 0, for example, 0x7FF0000000000001: indicates that it is not a numeric value

After reading the above, have you mastered the method of finding the best value in C language? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!

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