divmod
divmod dividend divisor
The quotient and the remainder of two integers of any size, as a list. The quotient is rounded down, as / of expr does, so the remainder has the sign of the divisor.
Examples
divmod 7 2gives3 1divmod -7 2gives-4 1
Errors
divmod 7 0gives the errordivide by zerodivmod 7.5 2gives the errordividend must be an integer
Facts
- Capability: none.
- Compute cost: one compute unit for the call, and more for the commands that it runs.
- Release: Tcl 9.1 only. A script has the command when ztcl follows Tcl 9.1, with
--tcl 9.1. See Tcl 9.1.
Differences from Tcl 8.6
- tclsh 9.1.0 gives a wrong quotient for
divmod 9223372036854775807 -1and ends with SIGFPE fordivmod -9223372036854775808 -1. ztcl gives the exact result.