Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading;
- using System.Globalization;
- namespace _13.ComparingFloats
- {
- class ComparingFloats
- {
- static void Main()
- {
- System.Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
- Console.WriteLine("Enter first number:");
- double firstNum = double.Parse(Console.ReadLine());
- Console.WriteLine("Enter second number:");
- double secondNum = double.Parse(Console.ReadLine());
- double eps = 0.000001;
- if (Math.Abs(firstNum - secondNum) < eps)
- {
- Console.WriteLine("The numbers are similar or equal.");
- }
- else if (Math.Abs(firstNum - secondNum) > eps)
- {
- Console.WriteLine("The numbers are NOT equal.");
- }
- else
- {
- Console.WriteLine("Wrong input.");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement