mayap

ComparingFloatingPointNums

Apr 11th, 2014
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.61 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 compareFloat
  8. {
  9.     class Program
  10.     {
  11.         static void Main()
  12.         {
  13.             Console.WriteLine("Enter the first number: ");
  14.             decimal firstNumber = decimal.Parse(Console.ReadLine());
  15.             Console.WriteLine("Enter the second number: ");
  16.             decimal secondNumber = decimal.Parse(Console.ReadLine());
  17.             bool comparing = (Math.Abs(firstNumber - secondNumber) < 0.000001m);
  18.             Console.WriteLine(comparing);
  19.         }
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment