Round a number to any number of decimal places (or to the nearest ten, hundred, etc.), with nearest/up/down modes.
A negative value rounds to the nearest ten, hundred, thousand, and so on — e.g. -1 rounds to the nearest 10, and -2 rounds to the nearest 100, instead of rounding after the decimal point.
Nearest uses standard rounding (0.5 rounds away from zero). Up always rounds toward positive infinity (ceiling) even for numbers that are already close to the lower value, and Down always rounds toward negative infinity (floor), regardless of how close the number is to the next value up.
The number is multiplied by 10 raised to the chosen number of places, rounded (or ceiled/floored) to a whole number, then divided back by that same power of 10 — this shifts the desired digit to the ones place so standard integer rounding can be applied.