Skip to main content

Function: stepValue()

function stepValue(value, step): number;

Defined in: math.ts:39

Put a value on the grid the caller asked for, rounding a half step upwards.

The rounding is done on the quotient rather than by comparing the distance to the two neighbours, because both of those carry error of their own. The quotient is cleared of its artefact first: 0.15 / 0.1 is 1.4999999999999998, and a value sitting exactly on a half step would otherwise fall to whichever side the last bit happened to land on — 0.25 rounded up while 0.15 and 0.35 rounded down.

Parameters​

ParameterType
valuenumber
stepnumber

Returns​

number