pub fn exhaustive_nonzero_finite_primitive_floats<T: PrimitiveFloat>(
) -> ExhaustiveNonzeroFinitePrimitiveFloats<T>Notable traits for ExhaustiveNonzeroFinitePrimitiveFloats<T>impl<T: PrimitiveFloat> Iterator for ExhaustiveNonzeroFinitePrimitiveFloats<T> type Item = T;
Expand description

Generates all finite nonzero primitive floats.

Positive and negative zero are both excluded.

Roughly speaking, the simplest floats are generated first. If you want to generate the floats in ascending order instead, use nonzero_finite_primitive_floats_increasing.

The output length is $2^{M+1}(2^E-1)-2$.

  • For f32, this is $2^{32}-2^{24}-2$, or 4278190078.
  • For f64, this is $2^{64}-2^{53}-2$, or 18437736874454810622.

Complexity per iteration

Constant time and additional memory.

Examples

use malachite_base::iterators::prefix_to_string;
use malachite_base::num::exhaustive::exhaustive_nonzero_finite_primitive_floats;
use malachite_base::num::float::NiceFloat;

assert_eq!(
    prefix_to_string(exhaustive_nonzero_finite_primitive_floats::<f32>().map(NiceFloat), 50),
    "[1.0, -1.0, 2.0, -2.0, 1.5, -1.5, 0.5, -0.5, 1.25, -1.25, 3.0, -3.0, 1.75, -1.75, 4.0, \
    -4.0, 1.125, -1.125, 2.5, -2.5, 1.375, -1.375, 0.75, -0.75, 1.625, -1.625, 3.5, -3.5, \
    1.875, -1.875, 0.25, -0.25, 1.0625, -1.0625, 2.25, -2.25, 1.1875, -1.1875, 0.625, -0.625, \
    1.3125, -1.3125, 2.75, -2.75, 1.4375, -1.4375, 6.0, -6.0, 1.5625, -1.5625, ...]"
);