Skip to content

Modern Math DivMod

Paul Squires edited this page Sep 30, 2026 · 5 revisions

Home › Math Library › Math Library › DivMod

DivMod

returns a TUPLE

Syntax

DivMod( a, b )

Notes

  • returns a TUPLE

Examples

#import "std/numeric"
using FB

'' 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
Source: docs/math/math.txt in the FBC-Modern repository.

Clone this wiki locally