Working with the random number generator


Closed Thread
Results 1 to 10 of 10

Hybrid View

  1. #1
    Join Date
    Jan 2007
    Posts
    8


    Did you find this post helpful? Yes | No

    Default random numbers

    It is about 20 pages long. basically it lists the functions available in pic basic and a single line about syntax. in my case it is the "Let" function. So

    Here is the only reference to division:

    {LET} Var = {-} Value { Op Value}

    Assigns a value to a variable. the valuemay be a conmstant, the value of another variable or the result of one or more binary operations. The operations are performed strictly left to right and all operations are performed with 16-bit precision. Unary negation may only be performed on the first value.

    It then lists a number of mathamatical opoerators {+, -, \, \\,....} and some boolean operators { and , or, xand, .....etc}. Nothing about truncating a number, rounding, absolute value, ...etc.

    I think I have a way out, I do the division and instead of truncating and rounding off and look=king for (X = a number 1 to 5) i can test for (X <= to a number). So anything (<= to 1) is 1, (<= to 2) is 2...etc. what do yo think?

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by kwelna View Post
    It is about 20 pages long. basically it lists the functions available in pic basic and a single line about syntax. in my case it is the "Let" function. So

    Here is the only reference to division:

    {LET} Var = {-} Value { Op Value}

    Assigns a value to a variable. the valuemay be a conmstant, the value of another variable or the result of one or more binary operations. The operations are performed strictly left to right and all operations are performed with 16-bit precision. Unary negation may only be performed on the first value.

    It then lists a number of mathamatical opoerators {+, -, \, \\,....} and some boolean operators { and , or, xand, .....etc}. Nothing about truncating a number, rounding, absolute value, ...etc.

    I think I have a way out, I do the division and instead of truncating and rounding off and look=king for (X = a number 1 to 5) i can test for (X <= to a number). So anything (<= to 1) is 1, (<= to 2) is 2...etc. what do yo think?


    I think you're not getting it...
    PBP doesn't deal with fractions. Fractions are ignored, thrown away, not present, not going to be in the final result, irrelavant...
    In our little world, 10 / 3 = 3 remainder 1, or 3 1/3, or 3.333333333(and so on)

    In PBP's world, 10 / 3 = 3, nothing more, nothing less.

    Do you get it yet?

  3. #3
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Wink With a little SEARCH

    Hi, Kwelna

    I remember there was a great discussion about random numbers ( here or in the PBP section ) ...

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  4. #4
    Join Date
    Jan 2007
    Posts
    8


    Did you find this post helpful? Yes | No

    Talking random numbers

    Oooh now I get it and the useage of the // function. OK so in essence, it always rounds down.....way easier. Sorry to be so thick

Similar Threads

  1. Random Numbers
    By BobEdge in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 18th December 2008, 09:47
  2. random generator with a limiter
    By kenpo in forum PBP Wish List
    Replies: 11
    Last Post: - 28th April 2007, 11:07
  3. Random number seed
    By kwelna in forum mel PIC BASIC
    Replies: 10
    Last Post: - 1st February 2007, 18:33
  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 : 2

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