Vz.Nice
Nicing numbers.
XXX Maybe move that to Gg.Float
Nice numbers for nice labels and ticks.
step n v0 v1
is a nice step size for sampling the directed interval [v0
;v1
] approximatively n
times. The step size is in the set { q⋅10z | q ∈ {1,2,5} and z ∈ Z } or 0
if v0 = v1
. Raises Invalid_argument
if n <= 0
.
Given a positive step size step
the following functions nice numbers so that they belong to the set Q(step
) = { z⋅step
| z ∈ Z }.
step_floor step v
is the greatest v'
such that v' <= v
and v'
∈ Q(step
). Raises Invalid_argument
if step <= 0.
.
step_ceil step v
is the smallest v'
such that v <= v'
and v'
∈ Q(step
). Raises Invalid_argument
if step <= 0.
.
step_round step v
is either step_floor v
or ceil_floor v
whichever is the nearest. Ties are rounded towards away from zero. Raises Invalid_argument
if step <= 0.
.
step_fold step f acc v0 v1
folds f
over set of numbers Q(step
) ∩ [v0
;v1
]. Folding is performed in order and in the direction from v0
to v1
. The integer given to f
is the fractional precision of the numbers mandated by step
. Raises Invalid_argument
if step <= 0.
.
step_outset step v0 v1
expands the directed interval [v0
;v1
] to (v0',v1')
∈ Q(step
)2 where v0'
(resp. v1'
) is the nearest number to v0
(resp. v1
). Raises Invalid_argument
if step <= 0.
.