truncate, ceiling, floor, and...?

554 Views Asked by At

Truncation rounds negative numbers upwards, and positive numbers downwards. Floor rounds all numbers downwards, and ceiling rounds all numbers upwards. Is there a term/notation/whatever for the fourth operation, which rounds negative numbers downwards, and positive numbers upwards? That is, one which maximizes magnitude as truncation minimizes magnitude?

1

There are 1 best solutions below

1
On BEST ANSWER

The fourth operation is called "round towards infinity" or "round away from zero". It can be implemented by

$$y=\text{sign} (x)\text{ceil}(|x|)$$