Advertisement
bacco

Comparing floats

May 23rd, 2018
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.50 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ComparingFloats
  4. {
  5.     class MainClass
  6.     {
  7.         public static void Main(string[] args)
  8.         {
  9.             double a = double.Parse(Console.ReadLine());
  10.             double b = double.Parse(Console.ReadLine());
  11.             double eps = 0.000001;
  12.             if (Math.Abs(a - b) < eps)
  13.             {
  14.                 Console.WriteLine("True");
  15.             }
  16.             else
  17.             {
  18.                 Console.WriteLine("False");
  19.             }
  20.         }
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement