Repository: godot
Issue: Bug in `fmod` when `a / b` is integer and `b` is small 
Labels: discussion,documentation

**Godot version:**
3.3.2, 4.0.dev.calinou.94c31ba30

**OS/device including version:**
Kubuntu 21.04 (not related)

**Issue description:**
In the Russian-speaking Godot community, one person complained about the "low accuracy" of `fmod` and gave the following example:

```gdscript
fmod(55.5, 0.1) != 0.0
```

I checked and it looks like the error only happens when `a / b` is integer and `b` is small. A number close to `b` is returned instead of `0.0`. ~~Perhaps this is due to the compensation for the float error, since in some cases `fmod` gives a more correct result than `x_fmod` (see example with `fmod(6.5, 1.5)`).~~

Thanks to **Alexey Zotov** for pointing out the error.

**Steps to reproduce:**
```gdscript
tool
extends EditorScript

func x_fmod(a: float, b: float) -> float:
    return a - int(a / b) * b

func test(a: float, b: float) -> void:
    var r1 := fmod(a, b)
    var r2 := x_fmod(a, b)
    print("%6.2f %6.2f %20.16f %20.16f %-5s %-5s" % [a, b, r1, r2,
            str(r1 == r2), str(is_equal_approx(r1, r2))])

func _run() -> void:
    test(55.5, 0.1)
    print()
    
    test(6.0, 1.5)
    test(6.2, 1.5)
    test(-6.0, 1.5)
    test(-6.2, 1.5)
    test(6.0, -1.5)
    test(6.2, -1.5)
    test(-6.0, -1.5)
    test(-6.2, -1.5)
    print()
    
    test(6.0, 0.5)
    test(6.2, 0.5)
    test(-6.0, 0.5)
    test(-6.2, 0.5)
    test(6.0, -0.5)
    test(6.2, -0.5)
    test(-6.0, -0.5)
    test(-6.2, -0.5)
    print()
    
    test(6.0, 0.05)
    test(-6.0, 0.05)
    test(6.0, -0.05)
    test(-6.0, -0.05)
    print()
    
    test(6.21, 0.05)
    test(-6.21, 0.05)
    test(6.21, -0.05)
    test(-6.21, -0.05)
    print()
    
    test(0.05, 6.0)
    print()
    
    test(6.5, 1.5)
    print()
    
    test(6.554_634_545_343, 1.567_684_556_575)
```

```
 55.50   0.10   0.0999999999999969   0.0000000000000000 False False

  6.00   1.50   0.0000000000000000   0.0000000000000000 True  True 
  6.20   1.50   0.2000000000000002   0.2000000000000002 True  True 
 -6.00   1.50  -0.0000000000000000   0.0000000000000000 True  True 
 -6.20   1.50  -0.2000000000000002  -0.2000000000000002 True  True 
  6.00  -1.50   0.0000000000000000   0.0000000000000000 True  True 
  6.20  -1.50   0.2000000000000002   0.2000000000000002 True  True 
 -6.00  -1.50  -0.0000000000000000   0.0000000000000000 True  True 
 -6.20  -1.50  -0.2000000000000002  -0.2000000000000002 True  True 

  6.00   0.50   0.0000000000000000   0.0000000000000000 True  True 
  6.20   0.50   0.2000000000000002   0.2000000000000002 True  True 
 -6.00   0.50  -0.0000000000000000   0.0000000000000000 True  True 
 -6.20   0.50  -0.2000000000000002  -0.2000000000000002 True  True 
  6.00  -0.50   0.0000000000000000   0.0000000000000000 True  True 
  6.20  -0.50   0.2000000000000002   0.2000000000000002 True  True 
 -6.00  -0.50  -0.0000000000000000   0.0000000000000000 True  True 
 -6.20  -0.50  -0.2000000000000002  -0.2000000000000002 True  True 

  6.00   0.05   0.0499999999999997   0.0000000000000000 False False
 -6.00   0.05  -0.0499999999999997   0.0000000000000000 False False
  6.00  -0.05   0.0499999999999997   0.0000000000000000 False False
 -6.00  -0.05  -0.0499999999999997   0.0000000000000000 False False

  6.21   0.05   0.0099999999999996   0.0099999999999998 False True 
 -6.21   0.05  -0.0099999999999996  -0.0099999999999998 False True 
  6.21  -0.05   0.0099999999999996   0.0099999999999998 False True 
 -6.21  -0.05  -0.0099999999999996  -0.0099999999999998 False True 

  0.05   6.00   0.0500000000000000   0.0500000000000000 True  True 

  6.50   1.50   0.5000000000000000   0.5000000000000000 True  True 

  6.55   1.57   0.2838963190430004   0.2838963190430004 True  True 
```

**Minimal reproduction project:**
—