Advertisement
stefkay

ComparingFloats

Aug 31st, 2015
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.39 KB | None | 0 0
  1. using System;
  2.  
  3. class Program
  4. {
  5.     static void Main()
  6.     {
  7.         Console.Write("a = ");
  8.         double a = double.Parse(Console.ReadLine());
  9.         Console.Write("b = ");
  10.         double b = double.Parse(Console.ReadLine()); ;
  11.         double eps = 0.000001d;
  12.                      
  13.         bool isEqual = (Math.Abs(a-b) < eps);
  14.            
  15.         Console.WriteLine(isEqual);
  16.     }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement