首页 > 其他 > 详细

2.62 判断机器是否进行算数右移

时间:2020-05-10 21:13:39      阅读:84      评论:0      收藏:0      [点我收藏+]

//csapp 2.62

#include <stdio.h>                                                                                                                                                                 
//算数右移返回1,否则返回0
int int_shifts_are_arithmetic() 
{
    //return !~(-1>>1);
    unsigned int w = sizeof(int)<<3;
    return !~(1<<(w-1)>>(w-1));
}

int main(void)
{
    printf("expect:1, result:%d\r\n", int_shifts_are_arithmetic());
}

2.62 判断机器是否进行算数右移

原文:https://www.cnblogs.com/LonelyTraveler/p/12864659.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!