C中整数的最后一位的地址 [英] Address of last bit of an integer in C

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

问题描述

大家好..

如何在C中找到整数的最后一位的地址.


谢谢

解决方案

位"没有地址-它位于字节/字/长字中将有地址的特定位置.

您指的是最后一位"?最重要的?还是最不重要?

只是使情况变得更糟,没有针对整数的最高有效字节或最低有效字节的地址的标准-它取决于目标处理器是否为最低有效优先"(也称为"Little-endian")或最重要的第一"-也称为大尾数"

很抱歉,我们不能为您提供在代码中有效的答案:C系统可以是任意字节序的,并且一点都没有地址,因此无法指向!


如果您指的是2 ^ 0位,则无法获取该地址...您可以获取该整数的每个组成字节的地址

但是,这取决于 endian [ 16、32或64位 [ ^ ]


如果您指的是2 ^ 0位,则可以找到其值为2的整数模量的整数:INTEGER%2.

Hi All..

How can i find the address of last bit of an integer in C.


Thanks

解决方案

A "bit" doesn''t have an address - it is at a specific position within a byte / word / long word which will have an address.

And which bit do you mean is the "last bit"? The most significant? Or the least significant?

Just to make things worse, there is no standard for the address of the most or least significant byte of an integer - it depends on whether the target processor is "least-significant-first" - also known as "Little-endian" - or "most-significant-first" - also known as "Big-endian"

So sorry, we can''t give you an answer that works in code: C systems can be either-endian, and a bit doesn''t have an address, so can''t be pointed at!


if you mean the 2^0 bit, you can''t get the address of that ... you can get the address of each of the constituent bytes of that integer

However, that depends on the endian[^] format of the system AND the width of an integer in that system, 16, 32 or 64 bits[^]


If you mean the 2^0 bit, you can find its value with modulus 2 of the integer: INTEGER % 2.


这篇关于C中整数的最后一位的地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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