RE: [boost] Re: meta-double

Rob Stewart <stewart@sig.com> writes:
AFAIK, the only thing you can say about the size of int is that it must handle the INT_MIN to INT_MAX range on a given platform and the only thing you can say about short is that it is no bigger than int and at least one byte. Have I missed something that requires both to be at least 16 bits?
David Abrahams <dave@boost-consulting.com> writes:
Yes.
That's a bit gnomic. What you have missed Rob is that the standard requires SHRT_MIN <= -32767 and SHRT_MAX >= 32767. That implies short must have at least 16 bits. There is a similar requirement on long that means it must be at least 32 bits. -- Martin Bonner Martin.Bonner@Pitechnology.com Pi Technology, Milton Hall, Ely Road, Milton, Cambridge, CB4 6WZ, ENGLAND Tel: +44 (0)1223 441434

From: Martin Bonner <martin.bonner@pitechnology.com>
David Abrahams <dave@boost-consulting.com> writes:
Rob Stewart <stewart@sig.com> writes:
AFAIK, the only thing you can say about the size of int is that it must handle the INT_MIN to INT_MAX range on a given platform and the only thing you can say about short is that it is no bigger than int and at least one byte. Have I missed something that requires both to be at least 16 bits?
Yes.
That's a bit gnomic.
Indeed.
What you have missed Rob is that the standard requires SHRT_MIN <= -32767 and SHRT_MAX >= 32767. That implies short must have at least 16 bits.
There is a similar requirement on long that means it must be at least 32 bits.
Thanks for jumping in, but where is that in the standard? I have ISO/IEC 14882, 1st ed. What should I have? -- Rob Stewart stewart@sig.com Software Engineer http://www.sig.com Susquehanna International Group, LLP using std::disclaimer;

----- Original Message ----- From: "Rob Stewart" <stewart@sig.com>
From: Martin Bonner <martin.bonner@pitechnology.com>
What you have missed Rob is that the standard requires SHRT_MIN <= -32767 and SHRT_MAX >= 32767. That implies short must have at least 16 bits.
There is a similar requirement on long that means it must be at least 32 bits.
Thanks for jumping in, but where is that in the standard? I have ISO/IEC 14882, 1st ed. What should I have?
The C standard unfortunately. 18.2.1.1 footnote 182 & 183 says that the numeric_limits<short>::max is equal to SHRT_MAX and numeric_limits<short>::min is equal to SHRT_MIN. The C standard says the SHRT_MIN and SHRT_MAX should have an absolute values >= 32767. The std::numeric_limits<short>::max also has to return a value of type short, taken together this combination of rules implies that short has to be at least 16 bits. HTH Christopher Diggins http://www.cdiggins.com

Rob Stewart <stewart@sig.com> writes:
From: Martin Bonner <martin.bonner@pitechnology.com>
David Abrahams <dave@boost-consulting.com> writes:
Rob Stewart <stewart@sig.com> writes:
AFAIK, the only thing you can say about the size of int is that it must handle the INT_MIN to INT_MAX range on a given platform and the only thing you can say about short is that it is no bigger than int and at least one byte. Have I missed something that requires both to be at least 16 bits?
Yes.
That's a bit gnomic.
Indeed.
Sorry, it was a bit too short. What I meant was "it's in the standard; you can look it up as well as I can and I don't have time right now." But I guess I was wrong about that.
What you have missed Rob is that the standard requires SHRT_MIN <= -32767 and SHRT_MAX >= 32767. That implies short must have at least 16 bits.
There is a similar requirement on long that means it must be at least 32 bits.
Thanks for jumping in, but where is that in the standard? I have ISO/IEC 14882, 1st ed. What should I have?
It's in the 'C' standard, which is incorporated by reference into the C++ standard. I don't know where it is in C90, but in C99 it's in 5.2.4.2.1 HTH, -- Dave Abrahams Boost Consulting www.boost-consulting.com
participants (4)
-
christopher diggins
-
David Abrahams
-
Martin Bonner
-
Rob Stewart