divmod(n)

πŸ“¦ version 9.1.0, in nixpkgs unstable

πŸ’… divmod(n) β€” Tcl Integer Division πŸ’…

okay bestie, we're doing integer division but make it give you two whole values β€” quotient and remainder, no cap. ✨


🌸 NAME 🌸

divmod β€” divide an integer by another and report quotient and remainder. that's the tea. πŸ“

πŸŽ€ SYNOPSIS πŸŽ€

package require tcl 9.1

divmod x y

✨ DESCRIPTION ✨

So 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 β€” and it's set up so that the sum of the remainder and the product of the quotient and y is equal to x. literally the math is mathing. 🫢

The quotient and remainder are calculated using the same rules as for Tcl's / and % operators. periodt. πŸ’…

πŸ”₯ EXAMPLE πŸ”₯

lassign [divmod 123 50] q r
puts "quotient=$q remainder=$r"
#       quotient=2 remainder=23

πŸ¦‹ SEE ALSO πŸ¦‹

πŸ‘‘ KEYWORDS πŸ‘‘

  • division
  • integer value

xoxo, your Tcl 9.1 bestie β€” divmod(n) footer vibes πŸ’–

πŸ“¦ where this page comes from