TheBulgarianWolf

Floats comparisson

Oct 11th, 2020
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.79 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Numerics;
  4.  
  5. namespace SoftuniExercisesWithVariables
  6. {
  7.     class Program
  8.     {
  9.        
  10.         static void Main(string[] args)
  11.         {
  12.             Console.WriteLine("Enter the first float number:  ");
  13.             float firstFloat = float.Parse(Console.ReadLine());
  14.             Console.WriteLine("Enter the second float number: ");
  15.             float secondFloat = float.Parse(Console.ReadLine());
  16.             float floatCheck = 0.000001f;
  17.             if(Math.Abs(firstFloat-secondFloat) < floatCheck)
  18.             {
  19.                 Console.WriteLine("The floats are equal.");
  20.             }
  21.             else
  22.             {
  23.                 Console.WriteLine("The floats are not equal.");
  24.             }
  25.  
  26.         }
  27.     }
  28. }
  29.  
Add Comment
Please, Sign In to add comment