Advertisement
VladoG

[Programming Fundamentals] - 15. Comparing floats

Jun 1st, 2016
379
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.71 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace _15_Comparing_floats
  8.     {
  9.     class ComparingFloats
  10.         {
  11.         static void Main(string[] args)
  12.             {
  13.             double eps = 0.000001;
  14.             double diff = 0.0;
  15.             double a = double.Parse(Console.ReadLine());
  16.             double b = double.Parse(Console.ReadLine());
  17.  
  18.             diff = a - b;
  19.             if (Math.Abs(diff) < eps)
  20.                 {
  21.                 Console.WriteLine("True");
  22.                 }
  23.             else
  24.                 {
  25.                 Console.WriteLine("False");
  26.                 }
  27.             }
  28.         }
  29.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement