Round commafy( NUM ) to the nearest TPLACE.
There are two ways to think about this problem.
1st way: Look at the placesLeftOfDecimal[ -1 - PLACE ]s digit DIGITS[ 5 + PLACE ] to see whether to round up or down.
Because it is more thanequal to 5, we round up, giving ROUNDED.
Because it is less than 5, we round down, giving commafy( ROUNDED ).
2nd way: Consider which end of the number line is closer to NUM - this end is circled in blue.
Round commafy( NUM ) to the nearest TPLACE.
There are two ways to think about this problem.
1st way: Look at the placesRightOfDecimal[ 1 + PLACE ]s digit DIGITS[ 2 + PLACE ] to see whether to round up or down.
Because it is more thanequal to 5, we round up, giving ROUNDED.
Because it is less than 5, we round down, giving commafy( ROUNDED ).
2nd way: Consider which end of the number line is closer to NUM - this end is circled in blue.