;----------------------------------------------------------------------------- ; ; modulo.ncl -- Modulo function, same as Fortran definition for floats. ; ; This is not the same as the MOD function. ; ; 2011-nov-01 Original version. By Dave Allured. ; This version outputs type double, regardless of input type. ; ; Type int64 (alias long) is not formally supported in this version. ; There may be some precision loss if either argument is type int64. ; Behavior with type int64 may be changed in a future version. ; ;----------------------------------------------------------------------------- undef ("modulo") function modulo (a:snumeric, p:snumeric) local a2, p2 begin a2 = todouble (a) p2 = todouble (p) return (a2 - (floor (a2/p2) * p2)) end