kirililchev3

Comparing Floats

May 27th, 2018
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.46 KB | None | 0 0
  1. using System;
  2.  
  3. namespace P16_ComparingFloats
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             double num1 = double.Parse(Console.ReadLine());
  10.             double num2 = double.Parse(Console.ReadLine());
  11.             double diff = Math.Abs(num1 - num2);
  12.             const double eps = 0.000001;
  13.             bool areNumsRelativeEqual = diff < eps;
  14.             Console.WriteLine(areNumsRelativeEqual);
  15.         }
  16.     }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment