module Nice:`sig`

..`end`

Nicing numbers.

Nice numbers for nice labels and ticks.

`val step : ``int -> float -> float -> float`

`step n v0 v1`

is a nice step size for sampling the directed interval
[`v0`

;`v1`

] `n`

times. The step size is in
the set { q⋅10`0`

if
`v0 = v1`

.`Invalid_argument`

if `n`

is not strictly positive.
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`

`v0`

;`v1`

] to `(v0',v1')`

∈ Q(`step`

)`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`

`v0`

;`v1`

] to `(v0',v1')`

∈ Q(`step`

)`v0'`

(resp. `v1'`

) is the nearest number to `v0`

(resp. `v1`

).