VelizarAvramov

16. Comparing floats

Nov 28th, 2019
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.58 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _16._Comparing_floats
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             double a = Math.Abs(double.Parse(Console.ReadLine()));
  10.             double b = Math.Abs(double.Parse(Console.ReadLine()));
  11.  
  12.             double eps = 0.000001;
  13.             double diff = Math.Max(a,b) - Math.Min(a,b);
  14.  
  15.             if (diff > eps)
  16.             {
  17.                 Console.WriteLine("False");
  18.             }
  19.             else if (diff <= eps)
  20.             {
  21.                 Console.WriteLine("True");
  22.             }
  23.         }
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment