Skip to content

Modern Math DivMod

Paul Squires edited this page Oct 19, 2026 · 5 revisions

Home › Math Library › Math Library › DivMod

DivMod

Returns the quotient and the remainder of one division together, as a tuple.

Syntax

DivMod( a, b )

Notes

  • returns a TUPLE

Examples

#import "std/numeric"
using numeric

'' Quotient and remainder from ONE divide, returned as a TUPLE -- which
'' is where the tuple feature earns its keep
dim as int32 a = 17, b = 5

'' DESTRUCTURE it. The fields are named in the signature but the value
'' is taken apart positionally, so `.quotient` is error 18.
var (q, r) = DivMod( a, b )

print q                      '' 3
print r                      '' 2

'' Tuple identity is STRUCTURAL, so DivMod on LONG and on LONGINT give
'' different types and neither converts to the other

Library: Math Library
Category: Math Library
Documented under: Nothing Becomes A Keyword

Clone this wiki locally