Tcl 9.1/Tk9.1 Documentation > Tcl Commands, version 9.1b0 > divmod

Tcl/Tk Applications | Tcl Commands | Tk Commands | [incr Tcl] Package Commands | SQLite3 Package Commands | TDBC Package Commands | tdbc::mysql Package Commands | tdbc::odbc Package Commands | tdbc::postgres Package Commands | tdbc::sqlite3 Package Commands | Thread Package Commands | Tcl C API | Tk C API | [incr Tcl] Package C API | TDBC Package C API

NAME

divmod — Divide an integer by another and report quotient and remainder

SYNOPSIS

package require tcl 9.1
divmod x y

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

SEE ALSO

expr, mathfunc, mathop

KEYWORDS

division, integer value
Copyright © 2025 Donal Fellows