fork download
  1. using System;
  2.  
  3. public class Test
  4. {
  5. static float Reduce(float F, float L) {
  6. return F - L * (float)Math.Floor(F / L);
  7. }
  8.  
  9. public static void Main()
  10. {
  11. for (float f = -10; f < 10; f += 0.6f) {
  12. float A = f % 8.0f;
  13. float B = Reduce(f, 8.0f);
  14. Console.WriteLine("{0} = {1} = {2}", A, B, A == B);
  15. }
  16. }
  17. }
Success #stdin #stdout 0.04s 23904KB
stdin
Standard input is empty
stdout
-2 = 6 = False
-1.4 = 6.6 = False
-0.7999992 = 7.200001 = False
-0.1999989 = 7.800001 = False
-7.599999 = 0.400001 = False
-6.999999 = 1.000001 = False
-6.399999 = 1.600001 = False
-5.799999 = 2.200001 = False
-5.199999 = 2.800001 = False
-4.599999 = 3.400001 = False
-4 = 4 = False
-3.4 = 4.6 = False
-2.8 = 5.2 = False
-2.2 = 5.8 = False
-1.6 = 6.4 = False
-0.9999998 = 7 = False
-0.3999997 = 7.6 = False
0.2000003 = 0.2000003 = True
0.8000003 = 0.8000003 = True
1.4 = 1.4 = True
2 = 2 = True
2.6 = 2.6 = True
3.2 = 3.2 = True
3.8 = 3.8 = True
4.4 = 4.4 = True
5 = 5 = True
5.6 = 5.6 = True
6.2 = 6.2 = True
6.8 = 6.8 = True
7.4 = 7.4 = True
8 = 8 = True
0.5999994 = 0.5999994 = True
1.2 = 1.2 = True
1.8 = 1.8 = True