码迷,mamicode.com
首页 > 其他好文 > 详细

数值类型

时间:2015-06-10 15:37:01      阅读:90      评论:0      收藏:0      [点我收藏+]

标签:

数值后缀

  float f = 1.0f;

  double d = 1D;

  decimal d = 1.1m;

 数值类型转换

    int  x =1234;

   long y = x;

 short z = (short)x;

           int i=1;

         float f = i;

        int d = (int)f;

整形运算溢出检查运算符checked

    int a = int.MaxValue;

    checked{

             a++;    //抛出异常

     }

  unchecked 取消溢出检查

  位运算符

  ~

  &

   |

 ^

  <<

>>

  short 没有自己的运算符 x y 会转换成 int运算 结果也是 int

            short x = 1, y = 1;
            short z = (short)(x + y);

 

 

 

 

 

 

技术分享

 

数值类型

标签:

原文地址:http://www.cnblogs.com/hlhxd/p/4566046.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!