| #include <limits> /* std::numeric_limits */ |
| #include "igs_math_random.h" |
| |
| |
| |
| igs::math::random::random() : seed_(1) {} |
| |
| |
| void igs::math::random::seed(unsigned long seed) { this->seed_ = seed; } |
| unsigned long igs::math::random::seed(void) const { return this->seed_; } |
| |
| |
| long igs::math::random::next(void) { |
| this->seed_ = this->seed_ * 1103515245UL + 12345UL; |
| |
| return static_cast<long>( |
| (this->seed_) % |
| (static_cast<unsigned long>(std::numeric_limits<long>::max()) + 1UL)); |
| |
| |
| } |
| double igs::math::random::next_d(void) { |
| return static_cast<double>(this->next()) / |
| static_cast<double>(std::numeric_limits<long>::max()); |
| } |