// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; namespace E { public class Program { private const double EPS = 0.0000001; private static bool ZeroOrOne(double x) { return (x < EPS ) || (x > 1 - EPS); } public static void Test(double x) { Console.WriteLine("{0,3} {1,-5} {2,-5} {3,-5} {4,-5} {5,-5} {6,-5} {7,-5}", x, x - (int)x == 0, x - Math.Floor(x) == 0, x % 1 == 0, x.ToString().IndexOfAny(",.".ToCharArray()) < 0, ZeroOrOne(x - (int)x), ZeroOrOne(x - Math.Floor(x)), ZeroOrOne(x % 1)); } public static void Main(string[] args) { for(int i = 0; i < 100; i++) { Test(Math.Sqrt(i) * Math.Sqrt(i)); } } } }