Or use some small EPSILON value to fix the Fix function and to implemented comparison to zero with |A| < EPSION using Abs function like this:
cheers,Code:Option Explicit Private Const EPSILON As Double = 0.0000001 Private Sub Form_Load() Dim a#: a = 58333.31 Dim b#: b = -8333.33 Debug.Print "No remainder? -> "; Abs(fmod(a, b)) < EPSILON Debug.Print Format$(fmod(a, b), "0.0000") Debug.Print Format$(fmod(a, b), "0.00000000") Debug.Print Format$(fmod(a, b), "0.000000000000") End Sub Private Function fmod(value As Double, modulus As Double) As Double fmod = value - Fix(value / modulus + Sgn(value) * Sgn(modulus) * EPSILON) * modulus End Function
</wqw>




Reply With Quote
