POD的最小值和最大值 [英] Min and max of a POD
问题描述
在不使用任何外部定义(如INT_MIN,INT_MAX等)的情况下,获得最小值
和积分POD可以容纳的最大值的最佳方法是什么?b $ b?
类型(short,int,long等)加上signed / unsigned是已知的。
< blockquote> 7月2日,5:24 * pm,Adem24 < ade ... @ adem24adem24.org.invalidwrote:
获得最小值的最佳方法是什么?
和最大值值,一个整数POD可以保持
而不使用任何外部定义,如INT_MIN,INT_MAX等。
类型(short,int,long等)加上signed / unsigned众所周知。
为什么你不想使用外部定义?
这些常数的替代方案当然来自限制
即numeric_limits< int> :: max()
Joe Cook
7月2日,5:24 * pm ,Adem24, < ade ... @ adem24adem24.org.invalidwrote:
获得最小值的最佳方法是什么?
和最大值值,一个整数POD可以保持
而不使用任何外部定义,如INT_MIN,INT_MAX等。
类型(short,int,long等)加上signed / unsigned众所周知。
您是否愿意做出假设,例如两个补码
表示?如果没有这样的假设,我认为没有办法在没有外部定义的情况下查询最小值/最大值。有了这样的假设,可以在没有外部
定义的情况下查询签名。
-Howard
joseph cook写道:
7月2日下午5:24,Adem24 < ade ... @ adem24adem24.org.invalidwrote:
>获得最小值
的最佳方法是什么?积分POD可以保持
而不使用任何外部定义,如INT_MIN,INT_MAX等。
类型(短,整数,长等)加上有符号/无符号是已知的。
为什么你不想使用外部定义?
这些常数的替代方案当然来自限制
ie numeric_limits< int> :: max()
Joe Cook
仅供记录,numeric_limits< int> ; :: max()不能在Visual />
C ++下工作,因为它定义了两个名为min的宏。和max,所以
预处理器将尝试扩展宏,编译器将失败。它真的很糟糕。
发布通过Usenet.com高级Usenet新闻组服务
--------- -------------------------------------------------
http://www.usenet.com
What is the best way to get the minimum value
and the maximum value an integral POD can hold
without using any external definitions like INT_MIN, INT_MAX etc.?
The type (short, int, long, etc.) plus signed/unsigned is known.
On Jul 2, 5:24*pm, "Adem24" <ade...@adem24adem24.org.invalidwrote:What is the best way to get the minimum value
and the maximum value an integral POD can hold
without using any external definitions like INT_MIN, INT_MAX etc.?
The type (short, int, long, etc.) plus signed/unsigned is known.Why do you not want to use external definitions?
An alternative to those constants of course are from limits
i.e. numeric_limits<int>::max()
Joe Cook
On Jul 2, 5:24*pm, "Adem24" <ade...@adem24adem24.org.invalidwrote:What is the best way to get the minimum value
and the maximum value an integral POD can hold
without using any external definitions like INT_MIN, INT_MAX etc.?
The type (short, int, long, etc.) plus signed/unsigned is known.Would you be willing to make an assumption such as a two''s complement
representation? Without some assumption like that, I see no way to
query the min/max without external definitions. With such an
assumption, the signed-ness can be queried without external
definitions as well.
-Howard
joseph cook wrote:On Jul 2, 5:24 pm, "Adem24" <ade...@adem24adem24.org.invalidwrote:>What is the best way to get the minimum value
and the maximum value an integral POD can hold
without using any external definitions like INT_MIN, INT_MAX etc.?
The type (short, int, long, etc.) plus signed/unsigned is known.
Why do you not want to use external definitions?
An alternative to those constants of course are from limits
i.e. numeric_limits<int>::max()
Joe CookJust for the record, numeric_limits<int>::max() won''t work under Visual
C++ because it defines two macros called "min" and "max", so the
preprocessor will try to expand the macro and the compiler will fail. It
really sucks.
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
http://www.usenet.com
这篇关于POD的最小值和最大值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!