Advertisement
Guest User

Problem03.ComparingFloats

a guest
Mar 14th, 2014
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.58 KB | None | 0 0
  1. using System;
  2.  
  3. class ComparingFloats
  4. {
  5.     static void Main()
  6.     {
  7.         Console.WriteLine("Enter the first number :");
  8.         decimal FirstNum = decimal.Parse(Console.ReadLine());
  9.         Console.WriteLine("Enter the second number :");
  10.         decimal SecondNum = decimal.Parse(Console.ReadLine());
  11.        
  12.         if(Math.Abs(FirstNum - SecondNum) < 0.000001m)
  13.             Console.WriteLine("The two numbers are equal with precision 0.000001");
  14.         else
  15.             Console.WriteLine("The difference between the two numbers is more than (or equal to) 0.000001");
  16.     }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement