zoukankan      html  css  js  c++  java
  • C语言操作数截断

    //测试截断
    #include <stdio.h>
    int main()
    {
        
        int a = 0x80000001;
        unsigned int b = 0x80000001;
        printf("有符号数a的值是%d
    ", a);
        printf("无符号数b的值是%x
    ", b);
    
        //有符号数与无符号数的截断
        short c = (short)a;
        short c1 = (short)b;
        printf("有符号数a截断后的值是%hd
    ", c);
        printf("无符号数b截断后的值是%hd
    ", c1);
    
        //补码截断
        a = -1;
        printf("有符号数a的补码截断前的值是%x
    ", a);
        short d = (short)a;
        short d1 = (short)b;
        printf("有符号数a的补码截断后的值是%hx
    ", d);
        printf("有符号数a的补码截断后的值是%d
    ", d);
        printf("无符号数b的补码截断后值是%hd
    ", d1);
    
        return 0;
    }

  • 相关阅读:
    简易表格练习
    CSS圆角样式
    力不从心
    学渣在努力~
    嫌疑人
    poj1308 Is it a tree?
    悲剧文本
    迷宫问题
    n皇后问题
    油田
  • 原文地址:https://www.cnblogs.com/zzdbullet/p/9494192.html
Copyright © 2011-2022 走看看