FAQ问题:基本类型的保证值范围? [英] FAQ issue: Guaranteed value ranges of fundamental types?

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

问题描述

C ++ FAQ项目29.5(这似乎与C密切相关),

< url:http://www.parashift.com/c++-faq-lite/newbie。 html#faq-29.5>

提到


< quote>

C ++保证char正好是一个字节至少是8位,短的

至少是16位,int至少是16位,long是至少32位

< / quote>

问题:


(1)此保证似乎来自C标准。哪个我没有b $ b。 C ++标准是否真的能保证这一点?


(2)这种保证最初是根据比特数,

或者例如十进制值范围?


(3)关于(2),如果以比特数表示,则是数字

的比特简称sizeof( T)* CHAR_BIT,它没有多说

的值范围,或者它们被称为值表示位?

(故意交叉发布[comp] .lang.c ++]和[comp.lang.c])。


-

答:因为它弄乱了人们通常阅读的顺序文字。

问:为什么这么糟糕?

A:热门帖子。

问:什么是最烦人的事情在usenet和电子邮件中?

The C++ FAQ item 29.5 (this seems to be strongly related to C), at
<url: http://www.parashift.com/c++-faq-lite/newbie.html#faq-29.5>
mentions that

<quote>
C++ guarantees a char is exactly one byte which is at least 8 bits, short
is at least 16 bits, int is at least 16 bits, and long is at least 32
bits.
</quote>
Questions:

(1) This guarantee seems to come from the C standard. Which I don''t
have. Does the C++ standard really guarantee this?

(2) Is this guarantee originally formulated in terms of number of bits,
or in terms of e.g. decimal value ranges?

(3) Concerning (2), if formulated in terms of number of bits, are the number
of bits mentioned simply sizeof(T)*CHAR_BIT, which doesn''t say much about
value ranges, or are they stated to be the value representation bits?
(Intentionally cross-posted [comp.lang.c++] and [comp.lang.c]).

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?

推荐答案

Alf P. Steinbach写道:
Alf P. Steinbach wrote:

C ++常见问题解答项目29.5(这似乎与C密切相关),在
< url:http://www.parashift.com/c++-faq-lite/newbie.html#faq-29.5>
提到

< quote>
C ++保证char正好是一个字节,至少是8个bi ts,short
至少为16位,int至少为16位,
和long至少为32位。
< / quote>

问题:

(1)此保证似乎来自C标准。我没有。 C ++标准是否真的能保证这一点?

(2)这种保证最初是根据位数,
还是根据例如数字来制定的。十进制值范围?

The C++ FAQ item 29.5 (this seems to be strongly related to C), at
<url: http://www.parashift.com/c++-faq-lite/newbie.html#faq-29.5>
mentions that

<quote>
C++ guarantees a char is exactly
one byte which is at least 8 bits, short
is at least 16 bits, int is at least 16 bits,
and long is at least 32 bits.
</quote>

Questions:

(1) This guarantee seems to come from the C standard. Which I don''t
have. Does the C++ standard really guarantee this?

(2) Is this guarantee originally
formulated in terms of number of bits,
or in terms of e.g. decimal value ranges?




C标准中称为

整数类型的大小的部分。在C89和

整数类型的大小在C99中,

是按范围指定的。


C99描述了整数类型的填充位。


-

pete



The part of the C standard which is called
"Sizes of integral types" in C89 and
"Sizes of integer types" in C99,
is specified in terms of ranges.

C99 describes padding bits for integer types.

--
pete


" Alf P. Steinbach"写道:
"Alf P. Steinbach" wrote:

C ++ FAQ项目29.5(这似乎与C密切相关),
< url:http://www.parashift.com/c++ -faq-lite / newbie.html#faq-29.5>
提到

< quote>
C ++保证char只有一个字节,至少为8
位,short至少为16位,int至少为16位,
long至少为32位。
< / quote>

问题:

(1)此保证似乎来自C标准。我没有。 C ++标准真的能保证这一点吗?


我不知道。这是c.l.c.谷歌为N869获得了最后的草案

的C标准。 f''ups设置,你应该在

原始帖子中完成。

(2)这个保证最初是根据
位的数量来制定的或者就例如而言十进制值范围?


按价值计算。其他规范将其转化为可行位。

(3)关于(2),如果根据位数表示,则提到的位数就是sizeof(T)* CHAR_BIT ,
对价值范围说不多,还是说它们是价值表示位?

The C++ FAQ item 29.5 (this seems to be strongly related to C), at
<url: http://www.parashift.com/c++-faq-lite/newbie.html#faq-29.5>
mentions that

<quote>
C++ guarantees a char is exactly one byte which is at least 8
bits, short is at least 16 bits, int is at least 16 bits, and
long is at least 32 bits.
</quote>

Questions:

(1) This guarantee seems to come from the C standard. Which I
don''t have. Does the C++ standard really guarantee this?
I dunno. This is c.l.c. Google for N869 to get the last draft of
the C standard. f''ups set, which you should have done in the
original posting.

(2) Is this guarantee originally formulated in terms of number of
bits, or in terms of e.g. decimal value ranges?
By values. Other specifications translate that into viable bits.

(3) Concerning (2), if formulated in terms of number of bits, are
the number of bits mentioned simply sizeof(T)*CHAR_BIT, which
doesn''t say much about value ranges, or are they stated to be
the value representation bits?




不,因为可能有其他用途的位,例如陷阱

值。


-

"如果你想发布通过groups.google.com进行跟进,不要使用

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

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

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



No, because there may be bits for other purposes, such as trap
values.

--
"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


* CBFalconer:
* CBFalconer:
" Alf P. Steinbach"写道:
"Alf P. Steinbach" wrote:

C ++ FAQ项目29.5(这似乎与C密切相关),
< url:http://www.parashift.com/c++ -faq-lite / newbie.html#faq-29.5>
提到

< quote>
C ++保证char只有一个字节,至少为8
位,short至少为16位,int至少为16位,
long至少为32位。
< / quote>

问题:

(1)此保证似乎来自C标准。我没有。 C ++标准真的能保证这一点吗?

The C++ FAQ item 29.5 (this seems to be strongly related to C), at
<url: http://www.parashift.com/c++-faq-lite/newbie.html#faq-29.5>
mentions that

<quote>
C++ guarantees a char is exactly one byte which is at least 8
bits, short is at least 16 bits, int is at least 16 bits, and
long is at least 32 bits.
</quote>

Questions:

(1) This guarantee seems to come from the C standard. Which I
don''t have. Does the C++ standard really guarantee this?



我不知道。这是c.l.c. Google for N869获得了C标准的最后草案。 f''ups设置,您应该在
原始帖子中完成。



I dunno. This is c.l.c. Google for N869 to get the last draft of
the C standard. f''ups set, which you should have done in the
original posting.




故意交叉发布; F.U.T.覆盖。 :-)


感谢N869参考。


是的,C标准规定了[limits.h]文档中的最小范围,其中C ++标准是指C标准for。



It was intentionally cross-posted; F.U.T. overridden. :-)

Thanks for the "N869" reference.

Yes, the C standard specifies those minimum ranges in the documentation
of [limits.h], which the C++ standard refers to the C standard for.

(2)此保证最初是根据
位的数量,还是以例如十进制值范围?
(2) Is this guarantee originally formulated in terms of number of
bits, or in terms of e.g. decimal value ranges?



按值。其他规格将其转化为可行位。



By values. Other specifications translate that into viable bits.




-

答:因为它会扰乱人们通常阅读文本的顺序。

问:为什么这么糟糕?

A:热门发布。

问:usenet上最烦人的事情是什么?在电子邮件中?



--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?


这篇关于FAQ问题:基本类型的保证值范围?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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