Oracle round negative decimal_places?

2.1k views Asked by At

as we know and explained here The oracle ROUND function will round number up or down and i can choose how many digits after the , i want to use, but I saw a function that has a ROUND as below

Example:

select round(125.11,-1) from dual;

what the minus one means ?? what it dose here ????

1

There are 1 answers

0
Boneist On BEST ANSWER

As per the documentation:

ROUND returns n rounded to integer places to the right of the decimal point. If you omit integer, then n is rounded to zero places. If integer is negative, then n is rounded off to the left of the decimal point.

So:

  • round(n, 0) rounds n to the nearest unit
  • round(n, 1) rounds n to the nearest tenth
  • round(n, -1) rounds n to the nearest ten
  • round(n, 2) rounds n to the nearest hundredth
  • round(n, -2) rounds n to the nearest hundred

etc