Advertisement
TodorovH

ComparingFloats

Mar 9th, 2014
302
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. using System;
  2.  
  3. class ComparingFloats
  4. {
  5. static void Main()
  6. {
  7. Console.WriteLine();
  8. Console.Write("Enter the value for a: ");
  9. double a = double.Parse(Console.ReadLine());
  10. Console.WriteLine();
  11. Console.Write("Enter the value for b: ");
  12. double b = double.Parse(Console.ReadLine());
  13. Console.WriteLine();
  14. double eps = 0.000001d;
  15. double absAB = Math.Abs(a - b);
  16. bool compare = absAB >= eps;
  17. Console.WriteLine(!compare);
  18. }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement