class Number
Description
Extensions to the built-in Number object.
Prototype extends native JavaScript numbers in order to provide:
ObjectRangecompatibility, throughNumber#succ.- Ruby-like numerical loops with
Number#times. - Simple utility methods such as
Number#toColorPartandNumber#toPaddedString. - Instance-method aliases of many functions in the
Mathnamespace.
Methods
Instance methods
-
abs
Number#abs() -> NumberReturns the absolute value of the number.
-
ceil
Number#ceil() -> NumberReturns the smallest integer greater than or equal to the number.
-
floor
Number#floor() -> NumberReturns the largest integer less than or equal to the number.
-
round
Number#round() -> NumberRounds the number to the nearest integer.
-
succ
Number#succ() -> NumberReturns the successor of the current Number, as defined by current + 1. Used to make numbers compatible with ObjectRange.
-
times
Number#times(iterator) -> NumberCalls
iteratorthe specified number of times. The function takes an integer as the first parameter; it will start at 0 and be incremented after each invocation. -
toColorPart
Number#toColorPart() -> StringProduces a 2-digit hexadecimal representation of the number (which is therefore assumed to be in the [0..255] range). Useful for composing CSS color strings.
-
toJSON
Number#toJSON() -> StringReturns a JSON string representation of the number.
-
toPaddedString
Number#toPaddedString(length[, radix]) -> StringConverts the number into a string padded with 0s so that the string’s length is at least equal to
length. Takes an optionalradixargument which specifies the base to use for conversion.
