int类型的位数 [英] number of bits for an int type

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

问题描述

您好,

我如何知道int值使用的位数?

是sizeof(int)* CHAR_BIT对吗?


谢谢

Hello,
How can I know the number of bits used for an int value?
Is "sizeof(int) * CHAR_BIT" correct ?

thanks

推荐答案

evang ... @ cnam.fr写道:
evang...@cnam.fr wrote:

你好,

如何知道int值使用的位数?

是& ; sizeof(int)* CHAR_BIT"正确吗?


谢谢
Hello,
How can I know the number of bits used for an int value?
Is "sizeof(int) * CHAR_BIT" correct ?

thanks



是的。但请注意,除了unsigned char类型之外,并非所有其他类型的b / b组成部分都可能是值位,(即
的位保存存储在其中的数值)变量)。可能有一个或

更多的填充和陷阱位。


因此类型可表示的值范围无需与
$相关b $ b sizeof(T)* CHAR_BIT返回的值,其中T是类型。要知道范围,请使用< limits.hand< float.h>中的宏。

Yes. However note that except for the type unsigned char, not all the
constituent bits of other types may be value bits, (i.e. bits which
hold the numeric value stored in the variable). There may be one or
more padding and trap bits.

So the range of values representable by the type need not be related to
the value returned by sizeof(T) * CHAR_BIT where T is the type. For
knowing the range, use the macros in <limits.hand <float.h>.


santosh a écrit:
santosh a écrit :

evang ... @ cnam.fr写道:
evang...@cnam.fr wrote:

您好,

如何知道int值使用的位数?

是sizeof(int)* CHAR_BIT对吗?


谢谢
Hello,
How can I know the number of bits used for an int value?
Is "sizeof(int) * CHAR_BIT" correct ?

thanks



是的。但请注意,除了unsigned char类型之外,并非所有其他类型的b / b组成部分都可能是值位,(即
的位保存存储在其中的数值)变量)。可能有一个或

更多的填充和陷阱位。


因此类型可表示的值范围无需与
$相关b $ b sizeof(T)* CHAR_BIT返回的值,其中T是类型。要知道范围的

,请使用< limits.hand< float.h>中的宏。


Yes. However note that except for the type unsigned char, not all the
constituent bits of other types may be value bits, (i.e. bits which
hold the numeric value stored in the variable). There may be one or
more padding and trap bits.

So the range of values representable by the type need not be related to
the value returned by sizeof(T) * CHAR_BIT where T is the type. For
knowing the range, use the macros in <limits.hand <float.h>.



感谢您的帮助,

在我的程序中我操纵了许多我存储在dictionnary中的对象。

保存内存我将这些对象编码为整数数组,然后将它们插入到字典中。

所以假设在我的数组的每个元素中我都有

" sizeof(int)* CHAR_BIT"位?

thanks for your help,
in my program I manipulate many objects that I store in a dictionnary.
to save memory I encode these objects in arrays of ints before
inserting them in the dictionnary.
so is it right to assume that in each element of my array I have
"sizeof(int) * CHAR_BIT" bits?


ev ****** @ cnam .fr 写道:

santoshaécrit:
santosh a écrit :

evang ... @ cnam .fr写道:
evang...@cnam.fr wrote:

你好,

我怎么知道int值的位数?

是" sizeof(int)* CHAR_BIT"正确吗?

>

谢谢
Hello,
How can I know the number of bits used for an int value?
Is "sizeof(int) * CHAR_BIT" correct ?
>
thanks



是的。但请注意,除了unsigned char类型之外,并非所有其他类型的b / b组成部分都可能是值位,(即
的位保存存储在其中的数值)变量)。可能有一个或

更多的填充和陷阱位。


因此类型可表示的值范围无需与
$相关b $ b sizeof(T)* CHAR_BIT返回的值,其中T是类型。要知道范围的

,请使用< limits.hand< float.h>中的宏。

Yes. However note that except for the type unsigned char, not all the
constituent bits of other types may be value bits, (i.e. bits which
hold the numeric value stored in the variable). There may be one or
more padding and trap bits.

So the range of values representable by the type need not be related to
the value returned by sizeof(T) * CHAR_BIT where T is the type. For
knowing the range, use the macros in <limits.hand <float.h>.



感谢您的帮助,

在我的程序中我操纵了许多我存储在词典中的对象。

保存内存我将这些对象编码为整数数组,然后将它们插入到字典中。

所以假设在我的数组的每个元素中我都有

" sizeof(int)* CHAR_BIT"位?


thanks for your help,
in my program I manipulate many objects that I store in a dictionnary.
to save memory I encode these objects in arrays of ints before
inserting them in the dictionnary.
so is it right to assume that in each element of my array I have
"sizeof(int) * CHAR_BIT" bits?



是。


您可能还想通读:
http://c-faq.com/

Yes.

You might also want to read through:
http://c-faq.com/


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

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