Advertisement
filipm

Untitled

Mar 10th, 2014
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.49 KB | None | 0 0
  1. using System;
  2.  
  3. class CompareFloat
  4. {
  5.     static void Main()
  6.     {
  7.         double eps =  0.000001;
  8.         double[] numbersA = { 5.3, 5.00000001,-0.0000007,-4.999999};
  9.         double[] numbersB = {6.01,5.00000003,0.00000007,-4.999998 };
  10.  
  11.         for(int i =0;i<4;i++)
  12.         {
  13.            double test = numbersA[i]-numbersB[i];
  14.            Console.WriteLine("{0} - {1} = {2} - {3}",numbersA[i],numbersB[i],(decimal)test,Math.Abs(test)< eps);
  15.         }
  16.         Console.ReadLine();
  17.     }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement