Advertisement
NikolaySpasovTriset

13. Comparing Floats

Oct 14th, 2016
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.44 KB | None | 0 0
  1. using System;
  2.  
  3.  
  4. class Comparing_floats
  5. {
  6.     static void Main(string[] args)
  7.     {
  8.         double firstNum = double.Parse(Console.ReadLine());
  9.         double secondNum = double.Parse(Console.ReadLine());
  10.         double a = Math.Abs(firstNum - secondNum);
  11.  
  12.         if (a == 0 || a < 0.000001)
  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