Changeset 2536 for trunk/src/lol/math/rand.h
 Timestamp:
 Mar 1, 2013, 5:24:20 PM (10 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/src/lol/math/rand.h
r2526 r2536 34 34 } 35 35 36 template<> 37 inline half rand<half>(half a) { return a * std::rand() / RAND_MAX; } 38 template<> 39 inline float rand<float>(float a) { return a * std::rand() / RAND_MAX; } 40 template<> 41 inline double rand<double>(double a) { return a * std::rand() / RAND_MAX; } 42 template<> 43 inline ldouble rand<ldouble>(ldouble a) { return a * std::rand() / RAND_MAX; } 36 template<> inline half rand<half>(half a) 37 { 38 float f = (float)std::rand() / (float)RAND_MAX; 39 return (half)(a * f); 40 } 41 42 template<> inline float rand<float>(float a) 43 { 44 float f = (float)std::rand() / (float)RAND_MAX; 45 return a * f; 46 } 47 48 template<> inline double rand<double>(double a) 49 { 50 double f = (double)std::rand() / (double)RAND_MAX; 51 return a * f; 52 } 53 54 template<> inline ldouble rand<ldouble>(ldouble a) 55 { 56 ldouble f = (ldouble)std::rand() / (ldouble)RAND_MAX; 57 return a * f; 58 } 44 59 45 60 /* Twovalue random number generator  no need for specialisation */
Note: See TracChangeset
for help on using the changeset viewer.