zoukankan      html  css  js  c++  java
  • int在linux上的保存情况

    test.c
    1
    #include <stdio.h>
    2  int main()
    3 {
    4 int n_input=0;
    5 while (scanf("%d",&n_input)!=EOF)
    6 printf("\t%d\n",n_input);
    7
    8 return 0;
    9 }
    10  

    上述代码在ubuntu 10.4及centos上编译

    gcc -o test test.c

    运行./test

    输入

    1 -3333333333333333333333333333333333
    2  -4294967297
    3  -4294967296
    4  -4294967295
    5  0
    6  1
    7  65535
    8 65536
    9 65537
    10 2147483647
    11 2147483648
    12 2147483649
    13 4294967295
    14 4294967296
    15 4294967297
    16 2222222222222222222222222222222222

    输出为

    1 -2147483648
    2 -2147483648
    3 -2147483648
    4 -2147483648
    5 0
    6 1
    7 65535
    8 65536
    9 65537
    10 2147483647
    11 2147483647
    12 2147483647
    13 2147483647
    14 2147483647
    15 2147483647
    16 2147483647

    从上面归纳出一个结论

    在ubuntu 10.4及centos(可以推广为linux,具体系统需要验证),数据的保存情况,保存范围为[-2147483648,2147483647]

    如果在这个范围内的输入保存成输入的数

    否则如果大于最大值,则保存成最大值

      如果小于最小值,则保存成最小值

  • 相关阅读:
    avcodec_open2()分析
    CentOS 6.9 下安装DB2
    使用python操作mysql数据库
    python之tcp自动重连
    决策树算法
    文件夹自动同步工具
    KNN算法介绍
    go语言生成uuid
    golang之log rotate
    golang之tcp自动重连
  • 原文地址:https://www.cnblogs.com/eavn/p/1805911.html
Copyright © 2011-2022 走看看