Keil Logo

Random Number generation

Next Thread | Thread List | Previous Thread Start a Thread | Settings

Details Message
Author
ramakrishna rachumallu
Posted
13-Feb-2019 08:04 GMT
Toolset
None
New! 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?

Author
Andrew Neil
Posted
13-Feb-2019 10:31 GMT
Toolset
None
New! RE: Random Number generation

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: http://www.cplusplus.com/reference/cstdlib/rand/

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: http://blog.antronics.co.uk/2011/08/08/so-youre-thinking-of-starting-with-c/

Next Thread | Thread List | Previous Thread Start a Thread | Settings

  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.