randRange(3, 7)
pow(10, NUM_DIGITS - 1)
randRange(MAG, MAG * 10 - 1)
randRange(1, min(5, NUM_DIGITS - 1))
numberPlaceNames[PLACE].toString()
plural_form(numberPlaceNames[PLACE], 2).toString()
plural_form(numberPlaceNames[PLACE - 1], 2)
Math.round(roundTo(-PLACE, NUM))
digits(NUM)[PLACE - 1]
Round commafy(NUM)
to the nearest TPLACE.
ROUNDED
randRange(3, 7)
pow(10, NUM_DIGITS - 1)
randRange(1, min(5, NUM_DIGITS - 1))
numberPlaceNames[PLACE].toString()
plural_form(numberPlaceNames[PLACE], 2).toString()
(function() {
// Get a number with a 5 in PLACE position
var n = NUM_DIGITS - PLACE
var str = "" + randRange(MAG, MAG * 10 - 1);
str = str.substr(0, n) + "5" + str.substr(n + 1);
return parseInt(str, 10);
})()
plural_form(numberPlaceNames[PLACE - 1], 2)
Math.round(roundTo(-PLACE, NUM))
5
Round commafy(NUM)
to the nearest TPLACE.
ROUNDED
Because we want to round to the TPLACEPLURAL place, we need to look at the digit in the TPLACES place.
The digit in the TPLACES place is KEYDIGIT
.
Because KEYDIGIT
is more than 5
, we round up to commafy(ROUNDED)
.
Because the TPLACES place digit is KEYDIGIT
,
we round up to commafy(ROUNDED)
.
Because KEYDIGIT
is less than 5
, we round down to commafy(ROUNDED)
.