用位运算实现求绝对值-有效避开if-else判断

来源:互联网 发布:英文字体设计软件 编辑:程序博客网 时间:2024/05/01 22:36

    int out    = iNum;
    
int temp = iNum;
    temp      
= temp >> 31;
 
    
out = out ^ temp;
    
out = out - temp;


原创粉丝点击