13 years C/C++/C# programing, focus on embedded and mobile device development.

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

C#和VB中浮点数到整数的转换

 

/* C#
     int a1 = (int)(3.22324);//3
     int a2 = (int)(3.82324);//3
     int a3 = (int)(-3.22324);//3
     int a4 = (int)(-3.82324);//3

     int b1 = (int)Math.Round(3.22324);//3
     int b2 = (int)Math.Round(3.82324);//4
     int b3 = (int)Math.Round(-3.22324);//-3
     int b4 = (int)Math.Round(-3.82324);//-4

     int c1 = (int)Math.Ceiling(3.22324);//4
     int c2 = (int)Math.Ceiling(3.82324);//4
     int c3 = (int)Math.Ceiling(-3.22324);//-3
     int c4 = (int)Math.Ceiling(-3.82324);//-3

     int d1 = (int)Math.Floor(3.22324);//3
     int d2 = (int)Math.Floor(3.82324);//3
     int d3 = (int)Math.Floor(-3.22324);//-4
     int d4 = (int)Math.Floor(-3.82324);//-4
     * */
    /* VB
     a1 = Int(3.22324);//3
     a2 = Int(3.82324);//3
     a3 = Int(-3.22324);//-4
     a4 = Int(-3.82324);//-4
     * */

posted on 2008-08-13 11:28  woaiusd  阅读(1531)  评论(0编辑  收藏  举报