Advertisement
fbinnzhivko

Comparing floats

May 19th, 2016
346
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.38 KB | None | 0 0
  1. using System;
  2. class Program
  3. {
  4.     static void Main()
  5.     {
  6.         decimal a = decimal.Parse(Console.ReadLine());
  7.         decimal b = decimal.Parse(Console.ReadLine());
  8.  
  9.         decimal eps = 0.000001m;
  10.  
  11.         if (Math.Abs(a - b) < eps)
  12.         {
  13.             Console.WriteLine(true);
  14.         }
  15.         else
  16.         {
  17.             Console.WriteLine(false);
  18.         }
  19.     }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement