短整数范围? [英] Range of short int?

查看:172
本文介绍了短整数范围?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的C中的算法副本中由R. Sedgewick(第3版,1月

1999再版),这是在第71-72页:


我们认为短的int为一个可以取值为
-32768和32767之间的值的对象,而不是作为一个16位对象


我对C的理解是负面的号码应为-32767。他网站上的

勘误列表显示它是-32767,后来的印刷更改为

-32768。


哪个是正确的?

In my copy of "Algorithms in C" by R. Sedgewick (3rd edition, January
1999 reprint), this is on pages 71-72:

"we think of a short int as an object that can take on values between
-32768 and 32767, instead of as a 16-bit object"

My understanding of C is that the negative number should be -32767. The
errata list on his website shows that it was -32767 and was changed to
-32768 for subsequent printings.

Which is correct?

推荐答案

al ****************** @ hotmail.com 写道:
在我的C中的算法的副本作者:R。Sedgewick(第3版,1月
1999再版),这是在第71-72页:

我们将短整数视为一个可以取值之间的对象
-32768和32767,而不是作为16位对象

我对C的理解是负数应该是-32767。他网站上的勘误表列表显示它是-32767,后来打印更改为
-32768。

哪个是正确的?
In my copy of "Algorithms in C" by R. Sedgewick (3rd edition, January
1999 reprint), this is on pages 71-72:

"we think of a short int as an object that can take on values between
-32768 and 32767, instead of as a 16-bit object"

My understanding of C is that the negative number should be -32767. The
errata list on his website shows that it was -32767 and was changed to
-32768 for subsequent printings.

Which is correct?




签名短期int的最负值至少为-32767,在


Robert Gamble



The most negative value for a signed short int is at least -32767, on a
2''s complement machine this will be -32768.

Robert Gamble


< al ****************** @ hotmail.com>在消息中写道

news:11 ********************* @ f14g2000cwb.googlegro ups.com ...
<al******************@hotmail.com> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com...
我对C的理解是负数应该是-32767。他网站上的勘误表列表显示它是-32767,后来打印更改为
-32768。
My understanding of C is that the negative number should be -32767. The
errata list on his website shows that it was -32767 and was changed to
-32768 for subsequent printings.




0x8001 = -32767

0x8000 = -32768


多年前我记得这个,但是作为2'的补充问题,而不是C语言。


当时它被引用(至少在我占据的圈子中)为负零和负零。问题。我自己从来没有看到过这个问题,但是在为数学单元做微代码的人中,它造成了很大的影响。我似乎记得

甚至理解为什么这对他们来说是一个问题,尽管我已经忘记了这个

的时间距离。


- 比尔



0x8001 = -32767
0x8000 = -32768

I remember this from years ago, but as 2''s complement issue, not a C one.

At that time it was being referred to (at least in the circles I occupied) as
the "negative zero" issue. I never saw the problem myself, but it caused a big
flap amongst the guys doing the microcode for the math unit. I seem to recall
even understanding why it was an issue to them, though I''ve forgotten from this
distance in time.

- Bill


al ****************** @ hotmail.com 写道:

在我的副本中C语言中的算法作者:R。Sedgewick(第3版,1999年1月重印),这是在第71-72页:

我们认为短的int是一个可以接受值的对象<在-32768和32767之间,而不是作为一个16位对象

我对C的理解是负数应该是-32767。他网站上的勘误列表显示它是-32767
并且后续打印更改为-32768。

哪个是正确的?

In my copy of "Algorithms in C" by R. Sedgewick (3rd edition,
January 1999 reprint), this is on pages 71-72:

"we think of a short int as an object that can take on values
between -32768 and 32767, instead of as a 16-bit object"

My understanding of C is that the negative number should be
-32767. The errata list on his website shows that it was -32767
and was changed to -32768 for subsequent printings.

Which is correct?




两者都没有。这取决于系统的设计方式。您的系统的实际

值在< limits.h>中描述


-

"如果你想通过groups.google.com发布一个后续内容,不要使用

破坏的回复链接在文章的底部。点击

" show options"在文章的顶部,然后点击

回复在文章标题的底部。 - Keith Thompson

详情请见:< http://cfaj.freeshell.org/google/>



Neither. It depends on how the system was designed. The actual
values, for your system, are described in <limits.h>

--
"If you want to post a followup via groups.google.com, don''t use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
More details at: <http://cfaj.freeshell.org/google/>


这篇关于短整数范围?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆