This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Random Number generation

can I generate a random integer/float value between -1 to 1 or 0 to 1 in Keil Microvision 5. Initially, I used rand() function, but later I found that it is generating random values between 0 to 32767. Can I put some thresholds on the upper limit and lower limit?

  • This has nothing specifically to do with Keil.

    "I used rand() function, but later I found ..."

    When using library functions, it is always important to ensure that you know what they do before you use them.

    Don't guess - look it up.

    eg: www.cplusplus.com/.../

    The Standard library functions - like rand() - should be covered in your 'C' textbook

    Here are some 'C' learning & reference resources, including a free online textbook: blog.antronics.co.uk/.../