Skip to main content

Module round_numbers

Module round_numbers 

Source
Expand description

The round-number families: the powers, Fibonacci steps, and nearest-pick the floor_*, ceiling_*, and closest_* nodes and their native lowerings compute with.

Functions§

ceiling_fibonacci_val
Smallest Fibonacci number (1, 2, 3, 5, 8, …) that is >= x; 1.0 for x <= 1. Assumes positive_finite(x).
floor_fibonacci_val
Largest Fibonacci number (1, 2, 3, 5, 8, …) that is <= x, or 0.0 when x < 1 (nothing in the sequence is that small). Assumes finite x.
floor_pow2
Largest power of two 2^n <= x. Assumes positive_finite(x).
floor_pow10
Largest power of ten 10^n <= x. Assumes positive_finite(x).
pick_closest
Pick whichever of lo / hi is nearer to x by absolute distance. Ties resolve to lo (the floor), per the closest_* contract.
positive_finite
True only for a strictly-positive, finite x. All family selectors gate on this and return 0.0 otherwise, so x <= 0, NaN, and ±inf all fold to the zero magnitude without special-casing each node.