Thread
:
Templated Random Number Generator
View Single Post
Jul 6th, 2007, 7:09 PM
#
4
Ben.Dougall
Programmer
Join Date: Jul 2007
Location: London, Ontario, Canada
Posts: 34
Rep Power:
0
cpp Syntax
(
Toggle Plain Text
)
static_cast<T>
(
low +
rand
(
)
/
(
RAND_MAX
/
(
high - low
)
+
1
)
)
;
static_cast<T>(low + rand() / ( RAND_MAX / ( high - low ) + 1 ));
Thank you Lectric, the first link you gave me seems to have done the job.
Ben.Dougall
View Public Profile
Find More Posts by Ben.Dougall