位的一个数据类型数 [英] Number of bits in a data type

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

问题描述

我有一个分配两项任务,一是回位的数量在int类型的任何计算机上。我以为我会写我的功能,像这样:

I have two tasks for an assignment, one return the number of bits in type int on any machine. I thought I would write my function like so:

int CountIntBitsF() {
    int x = sizeof(int) / 8;
    return x;
}

这是否正确?

的第二部分是与宏返回任何数据类型的任何比特数,并且宏可以从limits.h中服用。我抬头limits.h中我的机器上,也 HTTP:// WWW .opengroup.org / onlinepubs / 007908799 / XSH / limits.h.html 的,但我不认为我真的了解任何这些将返回在任何数据类型的位数。有什么想法吗?谢谢你。

The second part is to return the number of any bits of any data type with a macro, and the macro can be taken from limits.h. I looked up limits.h on my machine, and also http://www.opengroup.org/onlinepubs/007908799/xsh/limits.h.html, but I don't think I really understand how any of those would return the number of bits in any data type. Any thoughts? Thanks.

推荐答案

这是 * ,而不是 /

至于第二部分,看到的数值限制部分。

As for the second part, see the "Numerical Limits" section.

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

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