zoukankan      html  css  js  c++  java
  • C#中double转int时需要注意的地方

    这是个很奇怪的问题  一个double的大于0的数字转int后 竟然变成了负数

    后来F12进入Int32里面看了发现 原来这个数字超过了Int32的最大值了
    Int32的范围:

            // 摘要:
            //     表示 System.Int32 的最大可能值。此字段为常数。
            public const int MaxValue = 2147483647;
            //
            // 摘要:
            //     表示 System.Int32 的最小可能值。此字段为常数。
            public const int MinValue = -2147483648;

    Int16的范围:

            // 摘要:
            //     表示 System.Int16 的最大可能值。此字段为常数。
            public const short MaxValue = 32767;
            //
            // 摘要:
            //     表示 System.Int16 的最小可能值。此字段为常数。
            public const short MinValue = -32768;

    Int64的范围:

            // 摘要:
            //     表示 Int64 的最大可能值。此字段为常数。
            public const long MaxValue = 9223372036854775807;
            //
            // 摘要:
            //     表示 Int64 的最小可能值。此字段为常数。
            public const long MinValue = -9223372036854775808;

     所以这里只能用Int64进行转换了。。。 

  • 相关阅读:
    Linux目录图解
    Linux-Monitor-Tools
    常用系统及工具下载
    vim 编辑器常规使用
    Win10 安装.NET framework 3.5
    Apache 2.4.6 新增虚拟目录
    html5
    CentOS 7 修改ssh端口
    CentOS7 设置密码复杂度
    CentOS 7安装 hping
  • 原文地址:https://www.cnblogs.com/EleMMent/p/3142184.html
Copyright © 2011-2022 走看看