round can deliver that
>> help round
USAGE:
ROUND n /even /down /half-down /floor /ceiling /half-ceiling /to scale
DESCRIPTION:
Returns the nearest integer. Halves round up (away from zero) by
default.
ROUND is a function value.
ARGUMENTS:
n -- The value to round (Type: number money time)
REFINEMENTS:
/even -- Halves round toward even results
/down -- Round toward zero, ignoring discarded digits. (truncate)
/half-down -- Halves round toward zero
/floor -- Round in negative direction
/ceiling -- Round in positive direction
/half-ceiling -- Halves round in positive direction
/to -- Return the nearest multiple of the scale parameter
scale -- Must be a non-zero value (Type: number money time)
>> round/to/even a 0.01
== 5.44
round/to b 0.01
== 5.45
>> round/to/even b 0.001
== 5.446
Shadow Raider wrote:
> Hello everybody,
> do you know if it exists a function for correct number truncation?
> Examples:
> a: 5.44321
> a: trunc 2 a
> print a
> == 5.44
> b: 5.44621
> b: trunc 2 b
> print b
> == 5.45
> b: 5.44621
> b: trunc 3 b
> print b
> == 55.446