Shop OBEX P1 Docs P2 Docs Learn Events
Help with random — Parallax Forums

Help with random

Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
edited 2008-11-23 05:04 in Propeller 1
AFAIK, this command give me a random number between 0 and 19.

t1_pos_x:=rr.random // 20

Is there a simple way (like above) to get a number between 3 and 19?

Thanks
OBC

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
New to the Propeller?

Getting started with a Propeller Protoboard?
Check out: Introduction to the Proboard & Propeller Cookbook 1.4
Updates to the Cookbook are now posted to: Propeller.warrantyvoid.us
Got an SD card connected? - PropDOS

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2008-11-23 04:17
    Well, 19 - 3 is 16, so you need a number between 0 and 16 so:

    t1_pos_x := (rr.random // 17) + 3
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2008-11-23 05:04
    Mike Green said...
    Well, 19 - 3 is 16, so you need a number between 0 and 16 so:

    t1_pos_x := (rr.random // 17) + 3

    <Forehead smack> doh! </Forehead smack>

    Thanks.. I see it now.. Just get a number between 0 and 16, then add three.

    OBC

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    New to the Propeller?

    Getting started with a Propeller Protoboard?
    Check out: Introduction to the Proboard & Propeller Cookbook 1.4
    Updates to the Cookbook are now posted to: Propeller.warrantyvoid.us
    Got an SD card connected? - PropDOS
Sign In or Register to comment.