namespace Console42 {
using System;
class Program {
static void Main( string[] args ) {
//Proof that using Single(float), or Double(double) is bad for money calculations.
double x = 0.1;
double y = x + x + x;
Console.WriteLine( y == 0.3 ); // Prints False
Console.WriteLine( Math.Abs( y - 0.3 ) < double.Epsilon ); // Prints False
}
}
}
No comments:
Post a Comment