_lrotl, _lrotr

本文介绍了在C语言中如何使用_lrotl和_lrotr函数进行位的旋转操作。通过示例代码展示了如何实现左旋和右旋,并给出了具体的运行结果。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

http://msdn.microsoft.com/zh-cn/beginner/a0w705h5.aspx


旋转位左移 (_lrotl) 或右边 (_lrotr)。

unsigned long _lrotl(
   unsigned long value,
   int shift 
);
unsigned long _lrotr(
   unsigned long value,
   int shift 
);

将旋转的值。

shift

转换 值的位的数目。

两个函数返回该旋转的值。 无错误返回。

_lrotl 和 _lrotr 功能由 shift 位旋转  。 _lrotl 旋转值。 _lrotr 旋转值权限。 两个包装函数位旋转 值的 一端到另一端。

实例

必需的头

_lrotl

stdlib.h

_lrotr

stdlib.h

有关更多兼容性信息,请参见中介绍的 兼容性 。

C 运行库的所有版本。

// crt_lrot.c

#include <stdlib.h>
#include <stdio.h>

int main( void )
{
   unsigned long val = 0x0fac35791;

   printf( "0x%8.8lx rotated left eight times is 0x%8.8lx\n", 
            val, _lrotl( val, 8 ) );
   printf( "0x%8.8lx rotated right four times is 0x%8.8lx\n", 
            val, _lrotr( val, 4 ) );
}
0xfac35791 rotated left eight times is 0xc35791fa
0xfac35791 rotated right four times is 0x1fac3579

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值