Hello
as i saw here : http://www.keil.com/support/man/docs/ca/ca_rand.htm The rand function generates a pseudo-random number between 0 and 32767. the rand range is 0-32767.
so why i get bigger number ?
Best Regards
Your second link seems to be related to the programming language inside the debugger - not related to the C runtime library that you use in your embedded device.
If you back up a couple of steps you find:
Debug Functions are a powerful feature of µVision and help in debugging and testing an application. Debug functions can: Extend the capabilities of the µVision Debugger. Generate external interrupts. Log memory contents to a file. Update analog input values periodically. Input serial data to an on-chip serial port.
So once more - is this really relevant to you? Are you writing a debug script for the IDE, or are you writing a C program to run in your microcontroller?
If writing a C program, then you should know the C language standard. And you should know that the value of the RAND_MAX define is the contract relevant for your program. This value is available for your source code.
my second link is different this page is about " µVision User's Guide " not "CARM User's Guide
http://www.keil.com/support/man/docs/uv4/uv4_rand.htm
The link you posted contains this text:
----- Home / CARM User's Guide Discontinued -----
1) CARM is not the compiler that gets installed when you download any current MDK-ARM package. 2) The page very clearly claims that the product is discontinued.
The information is obviously totally irrelevant for your case, just as the user manual for a 1977 Porche 911 Carrera 3.0 is totally irrelevant when figuring out how to replace a light bulb in a 2014 Porche Cayenne GTS.
Your #1 goal when looking for information is to ask yourself "Is this information relevant for me?" You wont get far by locking onto irrelevant information.
Thanks for your replay
But as µVision User's Guide said:
The rand function returns a random number in the range 0 to +32767
this must be as default where it isn't and you have to define "__USE_ANSI_EXAMPLE_RAND" to get 7fff max rand .
RAND_MAX isn't something Keil needs to describe to you.
You are expected to have read up on the standard definition of rand() and know about RAND_MAX - a compiler vendor can't invest the time to duplicate all information from the C language standard.
You, on the other hand, are not suppoed to use manual pages for a compiler you aren't even using - like the CARM link you posted.
Thanks Pier
May be it would help if you provided your test case code this is my Code :
uint16_t randu; randu=rand(); send_buffer[0]=uint8_t (randu); send_buffer[1]=uint8_t (randu>>8);
. the micro-processor you are using my microprocessor id lpc1788 and the version of the compiler/library involved and compiler :MKD-ARM 4.72.1
Isn't the range defined by RAND_MAX, and isn't that 0x7FFFFFFF in your situation
I fond it in stdlib! But what is it? we can set the max number returned by "rand()"? way nowhere mentioned about this ?
here is µVision User's Guide : http://www.keil.com/support/man/docs/uv4/uv4_rand.htm no mention !
A bit interesting that the link in the original post is to the CARM compiler.
With a clear red "Discontinued" displayed.
May be it would help if you provided your test case code, and the output you observe. Include with it a description of the micro-processor you are using, and the version of the compiler/library involved.
If you frame better questions/observations, you are likely to get better responses, than to describe some vague malady and hope some other lost soul has encountered it.
Isn't the range defined by RAND_MAX, and isn't that 0x7FFFFFFF in your situation?
Did you send the value as text (using sprintf() or similar)? Or did you send the value as two bytes binary? In which case you might have flipped the byte order.
Yes i have very simply i just send "rand()" return through serial an got bigger number !
anyone else had this experience ?
Do you? How?
Maybe something to ask Keil support?
View all questions in Keil forum