apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Takashi Sato <se...@lans-tv.com>
Subject Re: MAX_SIZE_T
Date Wed, 24 Oct 2007 16:41:44 GMT
On Tue, 23 Oct 2007 10:49:53 -0500
"William A. Rowe, Jr." <wrowe@rowe-clan.net> wrote:

> Would ~((apr_size_t)0) be a better mapping of the largest apr_size_t value
> on our more essoteric platforms than (apr_size_t)(-1) - which don't use the
> typical-of-microprocessor 2's compliment negation?

Though I'm not sure which would be better, as long as apr_size_t is unsigned integer type
(apr_size_t)(-1) is the largest apr_size_t value on any platforms because ISO/IEC 9899
<http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1124.pdf> says:

6.3.1.3 Signed and unsigned integers
When a value with integer type is converted to another integer type other than _Bool, if
the value can be represented by the new type, it is unchanged.
Otherwise, if the new type is unsigned, the value is converted by repeatedly adding or
subtracting one more than the maximum value that can be represented in the new type
until the value is in the range of the new type.
Otherwise, the new type is signed and the value cannot be represented in it; either the
result is implementation-defined or an implementation-defined signal is raised.

but I feel (apr_size_t)(-1) is a very difficult expression.

-- 
Takashi Sato
serai@lans-tv.com

Mime
View raw message