Function malachite_base::num::exhaustive::exhaustive_nonzero_primitive_floats
source · pub fn exhaustive_nonzero_primitive_floats<T: PrimitiveFloat>() -> Chain<IntoIter<T>, ExhaustiveNonzeroFinitePrimitiveFloats<T>> ⓘ
Expand description
Generates all nonzero primitive floats.
Positive and negative zero are both excluded. NaN is excluded as well.
Roughly speaking, the simplest floats are generated first. If you want to generate the floats in
ascending order instead, use nonzero_primitive_floats_increasing
.
The output length is $2^{M+1}(2^E-1)$.
- For
f32
, this is $2^{32}-2^{24}$, or 4278190080. - For
f64
, this is $2^{64}-2^{53}$, or 18437736874454810624.
§Complexity per iteration
Constant time and additional memory.
§Examples
use malachite_base::iterators::prefix_to_string;
use malachite_base::num::exhaustive::exhaustive_nonzero_primitive_floats;
use malachite_base::num::float::NiceFloat;
assert_eq!(
prefix_to_string(
exhaustive_nonzero_primitive_floats::<f32>().map(NiceFloat),
50
),
"[Infinity, -Infinity, 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, \
...]"
);