Artifact edc07af2332c794b0580042f391df0bf7049cea6841a45b87ac3c8b6827d8586:
- File doc/markdown/Tcl/divmod.md — part of check-in [53d963650f] at 2026-10-05 21:52:35 on branch tip-700 — - file location re-organisation (part 2 of 2) - added manual pages from Tcl 9.1: divmod, frexp, lfilter, modf, remquo, timer; incl. final conversions - unified timer.n - moved 'package prefer' into the alphabetical order of the other subcommands (user: Torsten, size: 983) [annotate] [blame] [check-ins using]
CommandName: divmod title: divmod ManualSection: n Version: 9.1 TclPart: Tcl TclDescription: Tcl Integer Division Links:
- expr(n)
- mathfunc(n)
- mathop(n) Keywords:
- division
- integer value Copyright:
- Copyright (c) 2025 Donal Fellows ---
Name
divmod - Divide an integer by another and report quotient and remainder
Synopsis
::: {.synopsis} ::: [package]{.cmd} [require]{.sub} [tcl]{.lit} [9.1]{.lit} [divmod]{.cmd} [x]{.arg} [y]{.arg} :::
Description
The divmod command takes two integer numbers, x and y, and returns a list of two values. The first element of the result is the whole quotient of x/y, and the second is the remainder such that the sum of the remainder and the product of the quotient and y is equal to x.
The quotient and remainder are calculated using the same rules as for Tcl's / and % operators.
Example
lassign [divmod 123 50] q r
puts "quotient=$q remainder=$r"
# quotient=2 remainder=23