pub fn exhaustive_primitive_floats_with_sci_exponent<T: PrimitiveFloat>(
    sci_exponent: i64
) -> ExhaustivePrimitiveFloatsWithExponent<T> 
Expand description

Generates all positive finite primitive floats with a specified sci-exponent.

Positive and negative zero are both excluded.

A finite positive primitive float may be uniquely expressed as $x = m_s2^e_s$, where $1 \leq m_s < 2$ and $e_s$ is an integer; then $e$ is the sci-exponent. An integer $e_s$ occurs as the sci-exponent of a float iff $2-2^{E-1}-M \leq e_s < 2^{E-1}$.

If $e_s \geq 2-2^{E-1}$ (the float is normal), the output length is $2^M$.

  • For f32, this is $2^{23}$, or 8388608.
  • For f64, this is $2^{52}$, or 4503599627370496.

If $e_s < 2-2^{E-1}$ (the float is subnormal), the output length is $2^{e_s+2^{E-1}+M-2}$.

  • For f32, this is $2^{e_s+149}$.
  • For f64, this is $2^{e_s+1074}$.

§Complexity per iteration

Constant time and additional memory.

§Panics

Panics if the sci-exponent is less than MIN_EXPONENT or greater than MAX_EXPONENT.

§Examples

use itertools::Itertools;
use malachite_base::iterators::prefix_to_string;
use malachite_base::num::exhaustive::exhaustive_primitive_floats_with_sci_exponent;
use malachite_base::num::float::NiceFloat;

assert_eq!(
    prefix_to_string(
        exhaustive_primitive_floats_with_sci_exponent::<f32>(0).map(NiceFloat),
        20
    ),
    "[1.0, 1.5, 1.25, 1.75, 1.125, 1.375, 1.625, 1.875, 1.0625, 1.1875, 1.3125, 1.4375, \
    1.5625, 1.6875, 1.8125, 1.9375, 1.03125, 1.09375, 1.15625, 1.21875, ...]",
);
assert_eq!(
    prefix_to_string(
        exhaustive_primitive_floats_with_sci_exponent::<f32>(4).map(NiceFloat),
        20
    ),
    "[16.0, 24.0, 20.0, 28.0, 18.0, 22.0, 26.0, 30.0, 17.0, 19.0, 21.0, 23.0, 25.0, 27.0, \
    29.0, 31.0, 16.5, 17.5, 18.5, 19.5, ...]"
);
assert_eq!(
    exhaustive_primitive_floats_with_sci_exponent::<f32>(-147).map(NiceFloat).collect_vec(),
    [6.0e-45, 8.0e-45, 7.0e-45, 1.0e-44].iter().copied().map(NiceFloat).collect_vec()
);