VelizarAvramov

16. Comparing floats

Nov 15th, 2018
500
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. using System.Numerics;
  3.  
  4. namespace Demo
  5. {
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             double first = double.Parse(Console.ReadLine());
  11.             double second = double.Parse(Console.ReadLine());
  12.  
  13.             double eps = 0.000001;
  14.  
  15.             double diff = Math.Max(first, second) - Math.Min(first, second);
  16.  
  17.             if (diff > eps)
  18.             {
  19.                 Console.WriteLine("False");
  20.             }
  21.             else
  22.             {
  23.                 Console.WriteLine("True");
  24.             }
  25.         }
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment