Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Highlighted
New Contributor
Posts: 7
Registered: ‎12-05-2012
My Device: BB10
My Carrier: Orange

random() on BB10

Hi 

 

The docs say regarding random() in stdlib.h

 

"The random() function uses a nonlinear additive feedback random-number generator employing a default state array size of 31 long integers to return successive pseudo-random numbers in the range from 0 to 2^31-1 "

 

However RAND_MAX is defined on the BB10 platform as 

#define RAND_MAX        32767u

 

Does this mean random only returns a number in the range 0 to 2^16-1  on BB10. I need a 32 bit RNG

 

Thanks

Developer
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: random() on BB10

Look for lrand48().

Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!