Skip to content

Modern Math NextInt

Paul Squires edited this page Oct 14, 2026 · 6 revisions

Home › Math Library › Math Library › NextInt

NextInt

INCLUSIVE both ends, matching FB's TO

Syntax

NextInt( lo, hi )

Notes

  • INCLUSIVE both ends, matching FB's TO

Examples

#import "std/numeric"
using numeric

dim r as Rng = RngFromEntropy( )
dim as int64 lo = 1, hi = 6

'' INCLUSIVE at both ends, and UNBIASED -- it rejects and retries rather
'' than taking a modulus, which would favour the low end of the range
dim as int64 v = r.NextInt( lo, hi )
print v >= lo andalso v <= hi             '' -1 (true)

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

Clone this wiki locally