Function malachite_base::num::exhaustive::exhaustive_primitive_float_range
source · pub fn exhaustive_primitive_float_range<T: PrimitiveFloat>(
a: T,
b: T,
) -> ExhaustivePrimitiveFloatInclusiveRange<T> ⓘ
Expand description
Generates all primitive floats in the half-open interval $[a, b)$.
Positive and negative zero are treated as two distinct values, with negative zero being smaller than zero.
The floats are generated in a way such that simpler floats (with lower precision) are generated
first. To generate floats in ascending order instead, use primitive_float_increasing_range
instead.
NiceFloat(a)
must be less than or equal to NiceFloat(b)
. If NiceFloat(a)
and
NiceFloat(b)
are equal, the range is empty.
Let $\varphi$ be
to_ordered_representation
:
The output length is $\varphi(b) - \varphi(a)$.
§Complexity per iteration
Constant time and additional memory.
§Panics
Panics if NiceFloat(a) > NiceFloat(b)
.
§Examples
use malachite_base::iterators::prefix_to_string;
use malachite_base::num::exhaustive::exhaustive_primitive_float_range;
use malachite_base::num::float::NiceFloat;
assert_eq!(
prefix_to_string(
exhaustive_primitive_float_range::<f32>(core::f32::consts::E, core::f32::consts::PI)
.map(NiceFloat),
50
),
"[3.0, 2.75, 2.875, 3.125, 2.8125, 2.9375, 3.0625, 2.71875, 2.78125, 2.84375, 2.90625, \
2.96875, 3.03125, 3.09375, 2.734375, 2.765625, 2.796875, 2.828125, 2.859375, 2.890625, \
2.921875, 2.953125, 2.984375, 3.015625, 3.046875, 3.078125, 3.109375, 3.140625, \
2.7265625, 2.7421875, 2.7578125, 2.7734375, 2.7890625, 2.8046875, 2.8203125, 2.8359375, \
2.8515625, 2.8671875, 2.8828125, 2.8984375, 2.9140625, 2.9296875, 2.9453125, 2.9609375, \
2.9765625, 2.9921875, 3.0078125, 3.0234375, 3.0390625, 3.0546875, ...]"
);