Home  >  Article  >  Backend Development  >  Is \"long\" Guaranteed to Be at Least 32 Bits in C ?

Is \"long\" Guaranteed to Be at Least 32 Bits in C ?

Linda Hamilton
Linda HamiltonOriginal
2024-10-26 17:23:02182browse

Is

Is "long" Guaranteed to be at Least 32 Bits?

While the C Standard dictates a hierarchical progression in the sizes of fundamental integral types (with "long int" being the largest), it does not explicitly mandate a specific bit width for "long." However, there is a crucial determinant that ensures "long" is at least 32 bits.

The C Standard inherits C's limits (18.3.2) for "LONG_MIN" and "LONG_MAX," which are defined as -(2^31 - 1) and (2^31 - 1), respectively. This implies that "long" must be capable of storing values in this range.

Additionally, "std::numeric_limits::min()" and "std::numeric_limits::max()" are specified to be equivalent to "LONG_MIN" and "LONG_MAX" (18.3.1.2). This means that "long" can represent the limits of type "long."

In conclusion, while "long" may have a variable bit representation in different implementations, it is guaranteed to be at least 32 bits due to the requirements for its minimum and maximum values. This is determined by the C limits inherited by C and the way "std::numeric_limits" handles those limits.

The above is the detailed content of Is \"long\" Guaranteed to Be at Least 32 Bits in C ?. 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