我决定予以扩大。 我可以这样做,因为我知道人数很多。
int real = (int)(dbl * multiplier);
我确信,单凭I dont有x128 CPU和记忆巴士,精子就会放慢。 采用数学是前所未有的问题。
sorry for the blur with casting to float earlier.
http://www.ohchr.org。 OK。 因此,我说,SO现在不再自由。 每一个问题现在都需要注意,因为时间上代价高昂...... 这就是我为什么不使用Decimals和Math的说法。
class Program
{
static void Main(string[] args)
{
Start();
Console.ReadLine();
}
static int TESTS = 10;
static int LOOPS = 50000;
static double d1 = 1.5530000000000002;
static double d2 = 1.5531;
static double dResult;
static int iResult;
static decimal cResult;
static void Start()
{
// actual test
for (int x = 0; x < TESTS; x++)
{
Stopwatch sw = new Stopwatch();
long tick1, tick2, tick3;
sw.Start();
for (int j = 0; j < LOOPS; j++)
{
dResult = Math.Round(d1 / 2.0, 4);
dResult = Math.Round(d2 / 2.0, 4);
}
sw.Stop();
tick1 = sw.ElapsedTicks;
sw.Restart();
for (int j = 0; j < LOOPS; j++)
{
iResult = (int)(d1 / 2.0 * 10000.0);
iResult = (int)(d2 / 2.0 * 10000.0);
}
sw.Stop();
tick2 = sw.ElapsedTicks;
sw.Restart();
for (int j = 0; j < LOOPS; j++)
{
cResult = decimal.Round((decimal)d1, 4);
cResult = decimal.Round((decimal)d2, 4);
}
sw.Stop();
tick3 = sw.ElapsedTicks;
Console.WriteLine("Math {0} Int {1} Decimal {2}", tick1, tick2, tick3);
}
}
}
第一部分是数学,其次是我打算使用(转而使用)的,第三是 Dec。
www.un.org/Depts/DGACM/index_spanish.htm 我的表7结果如下:12K标准、700个标准、35K标准。