| ... | @@ -77,8 +77,12 @@ pub struct Rand { | ... | @@ -77,8 +77,12 @@ pub struct Rand { |
| 77 | | 77 | |
| 78 | /// Get a floating point value in the range 0.0..1.0. | 78 | /// Get a floating point value in the range 0.0..1.0. |
| 79 | pub fn float(r: &Rand, inline T: type) -> T { | 79 | pub fn float(r: &Rand, inline T: type) -> T { |
| | 80 | // TODO Implement this way instead: |
| | 81 | // const int = @int_type(false, @sizeof(T) * 8); |
| | 82 | // const mask = ((1 << @float_mantissa_bit_count(T)) - 1); |
| | 83 | // const rand_bits = r.rng.scalar(int) & mask; |
| | 84 | // return @float_compose(T, false, 0, rand_bits) - 1.0 |
| 80 | const int_type = @int_type(false, @sizeof(T) * 8); | 85 | const int_type = @int_type(false, @sizeof(T) * 8); |
| 81 | // TODO switch statement for constant values | | |
| 82 | const precision = if (T == f32) { | 86 | const precision = if (T == f32) { |
| 83 | 16777216 | 87 | 16777216 |
| 84 | } else if (T == f64) { | 88 | } else if (T == f64) { |