What is it called to round a number to a closer integer (not rounding the decimals) (see text for explanation)

134 Views Asked by At

Like lets say 412 to 425 or 400 (if the multiples are 25) or 516 to 550 or 500 (if the multiples are 50).

I don't know this is not rounding but how would this go?

1

There are 1 best solutions below

1
On BEST ANSWER

I would probably call this "rounding to the nearest (integer) multiple of $n$." That is, if $n$ is some number (probably I would want it to be a positive integer, or perhaps the reciprocal of an integer, but there is no reason that it should be---any positive real number could work), then we can round a real number $x$ to the nearest multiple of $n$ as follows:

  1. Set $x_n$ to be $x$ modulo $n$. That is, take $m$ to be the largest integer such that $mn \le x$, then set $x_n = x - mn$.
  2. If $x_n < n/2$, round $x$ down to $mn$. If $x_n > n/2$, round $x$ up to $(m+1)n$. If $x_n = n/2$, round up or down according to some rule (always round up, always round down, banker's rounding, flip a coin, etc).