内在最小值 [英] Intrinsic Minimums

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

问题描述

我一直在搜索标准,以获取有关最低

"位数的信息。内在类型,但还没有能够找到它。有人可以指点我吗?


-JKop

I''ve been searching the Standard for info about the minimum
"bits" of the intrinsic types, but haven''t been able to
find it. Could anyone please point me to it?

-JKop

推荐答案

JKop< NU ** @ NULL.NULL>在新闻中写道:j%***************** @ news.indigo.ie:
JKop <NU**@NULL.NULL> wrote in news:j%*****************@news.indigo.ie:
我一直在寻找标准有关最小
位的信息内在类型,但无法找到它。有人可以指点我吗?
I''ve been searching the Standard for info about the minimum
"bits" of the intrinsic types, but haven''t been able to
find it. Could anyone please point me to it?




它没有定义。你得到的最好的是sizeof(char)== 1,sizeof

(短)< = sizeof(int)< = sizeof(long)。


但是,这是以字节为单位,而不是位。它的实现定义是如何在一个字节中使用多个位。 sizeof(int)是执行环境的

架构所建议的自然大小。 (第3.9节)


我认为CHAR_BIT指定了一个字符串中的位数......但是,这个
似乎是在C标准中定义的(在< limits.h>)



It''s not defined. Best you''ve got is that sizeof(char) == 1, and sizeof
(short) <= sizeof(int) <= sizeof(long).

However, that''s in bytes, not bits. It is implementation-defined as to how
many bits are in a byte. sizeof(int) is the "natural size suggested by the
architecture of the execution environment''. (Section 3.9)

And I think CHAR_BIT specifies the number of bits in a char... but that
appears to be defined in the C Standard (in <limits.h>)


2004年7月22日星期四22:10:35 GMT,Andre Kostur< nn ****** @ kostur。净>写道:
On Thu, 22 Jul 2004 22:10:35 GMT, Andre Kostur <nn******@kostur.net> wrote:
JKop< NU ** @ NULL.NULL>在新闻中写道:j%***************** @ news.indigo.ie:
JKop <NU**@NULL.NULL> wrote in news:j%*****************@news.indigo.ie:
我一直在寻找标准有关最小
位的信息内在类型,但无法找到它。有人可以指点我吗?
I''ve been searching the Standard for info about the minimum
"bits" of the intrinsic types, but haven''t been able to
find it. Could anyone please point me to it?



它没有定义。你得到的最好的是sizeof(char)== 1,sizeof
(短)< = sizeof(int)< = sizeof(long)。

但是,这是以字节为单位,而不是位。实现定义为
如何在一个字节中存在多个位。 sizeof(int)是执行环境的架构所暗示的自然大小。 (第3.9节)

我认为CHAR_BIT指定了char中的位数......但是,这似乎是在C标准中定义的(在< limits.h>中)



It''s not defined. Best you''ve got is that sizeof(char) == 1, and sizeof
(short) <= sizeof(int) <= sizeof(long).

However, that''s in bytes, not bits. It is implementation-defined as to
how
many bits are in a byte. sizeof(int) is the "natural size suggested by
the
architecture of the execution environment''. (Section 3.9)

And I think CHAR_BIT specifies the number of bits in a char... but that
appears to be defined in the C Standard (in <limits.h>)




C要求短> = 16位,int> = 16位,长> = 32位。

< limits.h>中对INT_MIN,INT_MAX等给出的约束暗示了这些

的最小值。据推测,C ++从C继承了这个。


john



C requires short >= 16 bits, int >= 16 bits, long >= 32 bits. These
minimums are implied by the constraints given on INT_MIN, INT_MAX etc. in
<limits.h>. Presumably C++ inherits this from C.

john


John Harrison发布:

John Harrison posted:

C要求短> = 16位,int> = 16位,长> = 32
位。在
< limits.h>中对INT_MIN,
INT_MAX等给出的约束暗示了这些最小值。据推测,C ++从C继承了这个。

john
C requires short >= 16 bits, int >= 16 bits, long >= 32 bits. These minimums are implied by the constraints given on INT_MIN, INT_MAX etc. in
<limits.h>. Presumably C++ inherits this from C.

john



我正在写一个'将使用Unicode的编程。要表示一个

Unicode字符,我需要一个可以设置为
65,536个不同可能值的数据类型;在今天的世界中,计算中的
相当于16位。 wchar_t是自然的

选择,但标准中是否有任何保证'

它将是16位?如果不是,那么是无符号的那么短暂的方式来回去?


这可能听起来有点奇怪,但......如果是无符号的短

必须至少16位,那么*必然*意味着

它:


A)必须能够持有65,536个不同的值。

B)并且能够存储0 - >范围内的整数。 65,535?


此外,签名的短期必须能够支持
之间的价值:


A)-32,767 - > 32,768


B)-32,768 - > 32,767


我也听说有些系统很笨(opps!

我的意思是设计得很差)有两个值为零,

导致:


-32,767 - > 32,767

例如,我不在乎是否有人告诉我它是3美元b $ b位,只要它能保持65,536个不同的值!

-JKop


I''m writing a prog that''ll use Unicode. To represent a
Unicode character, I need a data type that can be set to
65,536 distinct possible values; which in the today''s world
of computing equates to 16 bits. wchar_t is the natural
choice, but is there any guarantee in the standard that''ll
it''ll be 16 bits? If not, then is unsigned short the way to
go?

This might sound a bit odd, but... if an unsigned short
must be atleast 16 bits, then does that *necessarily* mean
that it:

A) Must be able to hold 65,536 distinct values.
B) And be able to store integers in the range 0 -> 65,535 ?

Furthermore, does a signed short int have to be able to
hold a value between:

A) -32,767 -> 32,768

B) -32,768 -> 32,767

I''ve also heard that some systems are stupid enough (opps!
I mean poorly enough designed) to have two values for zero,
resulting in:

-32,767 -> 32,767
For instance, I don''t care if some-one tells me it''s 3
bits, just so long as it can hold 65,536 distinct values!
-JKop


这篇关于内在最小值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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