# Module Vz.Nice

`module Nice: `sig` .. `end``
Nicing numbers.

Nice numbers for nice labels and ticks.

# Nice steps

`val step : `int -> float -> float -> float``
`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` is not strictly positive.

# Quantized nicing

Given a positive step size `step` the following functions nice numbers so that they belong to the set Q(`step`) = { z⋅`step` | z ∈ Z }.

Warning. All these functions raise `Invalid_argument` if `step` is not strictly positive.

`val step_floor : `step:float -> float -> float``
`step_floor step v` is the greatest `v'` such that `v' <= v` and `v'` ∈ Q(`step`).
`val step_ceil : `step:float -> float -> float``
`step_ceil step v` is the smallest `v'` such that `v <= v'` and `v'` ∈ Q(`step`).
`val step_round : `step:float -> float -> float``
`step_round step v` is either `step_floor v` or `ceil_floor v` whichever is the nearest. Ties are rounded towards positive infinity.
`val step_fold : `step:float -> ('a -> int -> float -> 'a) -> 'a -> float -> float -> 'a``
`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`.
`val step_outset : `step:float -> float -> float -> float * float``
`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`).
`val step_inset : `step:float -> float -> float -> float * float``
`step_inset step v0 v1` shrinks the directed interval [`v0`;`v1`] to `(v0',v1')` ∈ Q(`step`)2 where `v0'` (resp. `v1'`) is the nearest number to `v0` (resp. `v1`).