use of unsigned

Hiya,

for the creation of a random number I came a cross the this function:

...
srand ( (unsigned)time( NULL ));
...


could anyone please explain me the purpose of the expression (unsigned) in this context. My program works just as well without having used the expression (unsigned).



Thanks a lot for your answers
Andrea
unsigned generates a positive number .
hi adesh,

thanks for your answer,

is that the only purpose? Because time(NULL) produces (at least in my case) always positive numbers, so the (unsigned) would be superfluous in this context.

Is it that time(NULL) can, under some circumstances, produce negative numbers and hence unsigned is better put there ?

Thanks for your answers
Andrea (a complete beginner)

Generally such explicit casts are to suppress a compiler warning.
And rand() never generates negative values .
As from the documentation , its range is between
0 to RAND_MAX
Topic archived. No new replies allowed.