tcl::mathfunc fmod
Gives the remainder of a division of floats, with the sign of the dividend.
tcl::mathfunc::fmod X Y
expr {fmod(X, Y)}
Description
Gives X minus Y times the quotient X/Y cut toward zero. The result has the sign of X, so fmod(-7, 3) is -1.0, and -7 % 3 is 2. A zero Y or an infinite X is a domain error. An infinite Y gives X.
Arguments
| Argument | Type | Default | Description |
|---|---|---|---|
| X | number | required | The dividend. |
| Y | number | required | The nonzero divisor. |
Returns
A float.
Examples
% expr {fmod(7, 3)}
1.0
% expr {fmod(-7, 3)}
-1.0
% expr {fmod(7.5, 2)}
1.5
% expr {fmod(5, Inf)}
5.0
Errors
% expr {fmod(7, 0)}
domain error: argument not in valid range
-errorcode ARITH DOMAIN {domain error: argument not in valid range}
% expr {fmod(7)}
not enough arguments for math function "fmod"
-errorcode TCL WRONGARGS
Facts
- Capability
- None.
- Tcl release
- Tcl 9.1 and 8.6.
- Since
- ztcl 1.0.0-beta.1