RND
f = RND
Returns a random floating point number in the range 0 to 1.
Example 1
RANDOMIZE
print "Number between 0 and 1 : "; RND()
print "Number between 5 and 12 : "; (12 - 5) * RND() + 5
print "Number between -5 and -12: "; (-12 - -5) * RND() - 5
Example 2: Random true/false; random integer between low/high
' random true/false, subst 0 or 1 (or -1)
DEF randbin() = IFF(rnd<.5,"True ","False ")
' random integer number between low and high
DEF randlohi(lo, hi) = (RND * (hi - lo + 1))\1 + lo
RANDOMIZE
print randbin()
print randlohi(10,20)
Code samples using RND
003 conditional branching.bas
005 challenge.bas
006 arrays+.bas
100lines.bas
2048.bas
2048.bas
3d_torus.bas
3dtictac.bas
3dtorus.bas
3dttt.bas
3dttt.bas
7gables.bas
A Rubens, Peter Paul Landscape.bas
anball 1.0.bas
angel feather.bas
aquarium v2.bas
autumn scene.bas
B+B.bas
Ball.bas
betrayal: crows ii.bas
bezier's autograph book.bas
bezierbounce.bas
blackbox.bas
Blackbox.bas
blackjack.bas
BlackJack.bas
block.bas
bolmo.bas
bomb.bas
Math
ABS
ABSMAX
ABSMIN
ACOS
ACOSH
ACOT
ACOTH
ACSC
ACSCH
ASEC
ASECH
ASIN
ASINH
ATAN
ATAN2
ATANH
ATN
CEIL
COS
COSH
COT
COTH
CSC
CSCH
DEG
DERIV
DETERM
DIFFEQN
EXP
EXPRSEQ
FIX
FLOOR
FRAC
INT
INTERSECT
INVERSE
LINEQN
LOG
LOG10
M3APPLY
M3IDENT
M3ROTATE
M3SCALE
M3TRANS
MAX
MIN
POLYAREA
POLYCENT
POLYEXT
POW
PTDISTLN
PTDISTSEG
PTSIGN
RAD
RND
ROOT
ROUND
SEC
SECH
SEGCOS
SEGLEN
SEGSIN
SEQ
SGN
SIN
SINH
SQR
STATMEAN
STATMEANDEV
STATMEDIAN
STATSPREADP
STATSPREADS
STATSTD
SUM
SUMSQ
TAN
TANH
TRANSPOSE
If there is insufficient information on this page and you wish learn more about RND,
please send an email to smallbasic@gmail.com. You can help to improve information about
RND by submitting a pull request,
click View Source for details. Note, an offline language reference text file is also available - see the Download section.