请问double,float转成int是舍尾还是收尾?

解决方案 »

  1.   

    这种问题你试一下就知道了,为什么还要问呢
    using System;
    using System.Collections.Generic;
    using System.Text;namespace ConsoleApplication29
    {
        class Program
        {
            static void Main(string[] args)
            {
                double d1 = 3.52;
                double d2 = 2.34;
                float f1 = 34.734f;
                float f2 = 23.11f;            Console.WriteLine(Convert.ToInt32(d1).ToString());
                Console.WriteLine(Convert.ToInt32(d2).ToString());
                Console.WriteLine(Convert.ToInt32(f1).ToString());
                Console.WriteLine(Convert.ToInt32(f2).ToString());            Console.ReadLine();
            }
        }
    }结果是
    4
    2
    35
    23
      

  2.   

    强制转换时是舍尾.
    (int)(9.56F)    // 9
    (int)(3.777777)   //3