Capy-Bearer Documentation

nearest

lib call

Capy

function nearest(value : f32) f32
function nearest(value : f64) f64

Description

nearest() is round-half-to-even: nearest(2.5) is 2.0 and nearest(3.5) is 4.0. For round-half-up use floor(value + 0.5).

Parameters

value : a floating-point number

Return Values

The integral value closest to value, in the same type. A tie goes to the even neighbour.

Example

Capy

print(nearest(2.5), " ", nearest(3.5), " ", nearest(-1.4), "\n")

Output

2 4 -1