pub fn nonzero_primitive_floats_increasing<T: PrimitiveFloat>(
) -> NonzeroValues<PrimitiveFloatIncreasingRange<T>>
Expand description

Generates all nonzero primitive floats, in ascending order.

Positive and negative zero are both excluded.

NEGATIVE_INFINITY is generated first and POSITIVE_INFINITY is generated last. The returned iterator is double-ended, so it may be reversed.

Let $\varphi$ be to_ordered_representation:

The output is $$ (\varphi^{-1}(k))_ {k=0}^{2^M(2^E-1)-1} ⧺ (\varphi^{-1}(k))_ {k=2^M(2^E-1)+2}^{2^{M+1}(2^E-1)+1} $$.

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::basic::floats::PrimitiveFloat;
use malachite_base::num::exhaustive::nonzero_primitive_floats_increasing;
use malachite_base::num::float::NiceFloat;

assert_eq!(
    prefix_to_string(nonzero_primitive_floats_increasing::<f32>().map(NiceFloat), 20),
    "[-Infinity, -3.4028235e38, -3.4028233e38, -3.402823e38, -3.4028229e38, -3.4028227e38, \
    -3.4028225e38, -3.4028222e38, -3.402822e38, -3.4028218e38, -3.4028216e38, -3.4028214e38, \
    -3.4028212e38, -3.402821e38, -3.4028208e38, -3.4028206e38, -3.4028204e38, -3.4028202e38, \
    -3.40282e38, -3.4028198e38, ...]"
);
assert_eq!(
    prefix_to_string(nonzero_primitive_floats_increasing::<f32>().rev().map(NiceFloat), 20),
    "[Infinity, 3.4028235e38, 3.4028233e38, 3.402823e38, 3.4028229e38, 3.4028227e38, \
    3.4028225e38, 3.4028222e38, 3.402822e38, 3.4028218e38, 3.4028216e38, 3.4028214e38, \
    3.4028212e38, 3.402821e38, 3.4028208e38, 3.4028206e38, 3.4028204e38, 3.4028202e38, \
    3.40282e38, 3.4028198e38, ...]"
);