GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Download
  • News
  • Community
  • Resources
  • Language Reference
  • SmallBASIC Manual

This view

  • Original page
  • New address

GeezerVison is showing smallbasic.github.io — SmallBASIC | RND

Edit History

RND

f = RND

Home > Reference > Math

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   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   bonkers.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  
This page was last edited on Thu, 20 Jul 2023 10:38:56 +0200 | Markdown processed with pandoc 3.1.12.1
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.