Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class ComparingFloats
- {
- static void Main()
- {
- float a = 5.500001f;
- double b = 5.500001;
- float eps = 0.000001f;
- double difference = b - a;
- if (((difference <= eps) || (difference >= eps && difference <= 0.000009)) && (difference >= 0))
- {
- Console.WriteLine(a + " is equal to " + b + " with precision of 0.000001");
- }
- else if (difference > eps)
- {
- Console.WriteLine(b + " is bigger than " + a + " with precision of 0.000001");
- }
- else if (difference < eps)
- {
- Console.WriteLine(a + " is bigger than " + b + " with precision of 0.000001");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment