Random function - How to limit it ??


Results 1 to 19 of 19

Threaded View

  1. #3
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    easy way is to mask results

    if you mask with 3F you will get a max of 63 combination. may few lines of if then else can do the rest of the job....

    RANDOM MyRandomVar
    MyRandomVar=MyRandomVar & $3F

    if MyRandomVar>39 then
    MyRandomVar=MyrandomVar-39
    endif

    that's it!!!
    Last edited by mister_e; - 28th November 2004 at 23:50.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

Similar Threads

  1. Questions on random numbers and multiplexing LEDs
    By AaronM in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 17th June 2009, 05:22
  2. Random Numbers
    By BobEdge in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 18th December 2008, 09:47
  3. 6 random numbers limiting to 49 ?????
    By SuB-ZeRo in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 16th June 2005, 00:27
  4. Random number results
    By bartman in forum mel PIC BASIC
    Replies: 3
    Last Post: - 9th March 2005, 18:39
  5. more random number questions
    By bartman in forum mel PIC BASIC
    Replies: 1
    Last Post: - 14th November 2004, 18:55

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts