An integer or floating-point number.
It is a compile-time error for any type other than int or double
to attempt to extend or implement num.
- Implements
-
- Implemented by
Static Methods
-
parse(String input, [num onError(String input)])
→
num
-
Parses a string containing a number literal into a number.
Properties
-
int
hashCode
-
read-only
Returns a hash code for a numerical value.
-
bool
isNaN
-
read-only
True if the number is the double Not-a-Number value; otherwise, false.
-
bool
isNegative
-
read-only
True if the number is negative; otherwise, false.
-
bool
isInfinite
-
read-only
True if the number is positive infinity or negative infinity; otherwise,
false.
-
bool
isFinite
-
read-only
True if the number is finite; otherwise, false.
-
num
sign
-
read-only
Returns minus one, zero or plus one depending on the sign and
numerical value of the number.
Methods
-
compareTo(num other)
→
int
-
Compares this to other.
-
remainder(num other)
→
num
-
Returns the remainder of the truncating division of this by other.
-
abs()
→
num
-
Returns the absolute value of this num.
-
round()
→
int
-
Returns the integer closest to this.
-
floor()
→
int
-
Returns the greatest integer no greater than this.
-
ceil()
→
int
-
Returns the least integer no smaller than this.
-
truncate()
→
int
-
Returns the integer obtained by discarding any fractional
digits from this.
-
roundToDouble()
→
double
-
Returns the double integer value closest to this.
-
floorToDouble()
→
double
-
Returns the greatest double integer value no greater than this.
-
ceilToDouble()
→
double
-
Returns the least double integer value no smaller than this.
-
truncateToDouble()
→
double
-
Returns the double integer value obtained by discarding any fractional
digits from the double value of this.
-
clamp(num lowerLimit, num upperLimit)
→
num
-
Returns this num clamped to be in the range lowerLimit-upperLimit.
-
toInt()
→
int
-
Truncates this num to an integer and returns the result as an int.
-
toDouble()
→
double
-
Return this num as a double.
-
toStringAsFixed(int fractionDigits)
→
String
-
Returns a decimal-point string-representation of this.
-
toStringAsExponential([int fractionDigits])
→
String
-
Returns an exponential string-representation of this.
-
toStringAsPrecision(int precision)
→
String
-
Converts this to a double and returns a string representation with
exactly precision significant digits.
-
toString()
→
String
-
Returns the shortest string that correctly represent the input number.