… | |
… | |
470 | return !is_constant (num) ? get_range (num) // non-constant |
470 | return !is_constant (num) ? get_range (num) // non-constant |
471 | : num & (num - 1) ? (this->next () * (uint64_t)num) >> 32U // constant, non-power-of-two |
471 | : num & (num - 1) ? (this->next () * (uint64_t)num) >> 32U // constant, non-power-of-two |
472 | : this->next () & (num - 1); // constant, power-of-two |
472 | : this->next () & (num - 1); // constant, power-of-two |
473 | } |
473 | } |
474 | |
474 | |
475 | // return a number within (min .. max) |
475 | // return a number within the closed interval [min .. max] |
476 | int operator () (int r_min, int r_max) |
476 | int operator () (int r_min, int r_max) |
477 | { |
477 | { |
478 | return is_constant (r_min) && is_constant (r_max) && r_min <= r_max |
478 | return is_constant (r_min) && is_constant (r_max) && r_min <= r_max |
479 | ? r_min + operator ()(r_max - r_min + 1) |
479 | ? r_min + operator ()(r_max - r_min + 1) |
480 | : get_range (r_min, r_max); |
480 | : get_range (r_min, r_max); |
481 | } |
481 | } |
482 | |
482 | |
|
|
483 | // return a number within the closed interval [0..1] |
483 | double operator ()() |
484 | double operator ()() |
484 | { |
485 | { |
485 | return this->next () / (double)0xFFFFFFFFU; |
486 | return this->next () / (double)0xFFFFFFFFU; |
486 | } |
487 | } |
487 | |
488 | |