dart:core
num class
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.
- Implemented types
-
- Implementers
Constructors
- num()
Properties
- hashCode → int
read-only, override
- Returns a hash code for a numerical value. [...]
- isFinite → bool
read-only
- True if the number is finite; otherwise, false. [...]
- isInfinite → bool
read-only
- True if the number is positive infinity or negative infinity; otherwise, false.
- isNaN → bool
read-only
- True if the number is the double Not-a-Number value; otherwise, false.
- isNegative → bool
read-only
- True if the number is negative; otherwise, false. [...]
- sign → num
read-only
- Returns minus one, zero or plus one depending on the sign and numerical value of the number. [...]
- runtimeType → Type
read-only, inherited
- A representation of the runtime type of the object.
Methods
- abs() → num
- Returns the absolute value of this num.
- ceil() → int
- Returns the least integer no smaller than
this
. [...] - ceilToDouble() → double
- Returns the least double integer value no smaller than
this
. [...] - clamp(num lowerLimit, num upperLimit) → num
- Returns this num clamped to be in the range
lowerLimit
-upperLimit
. [...] - compareTo(num other) → int
override
- Compares this to
other
. [...] - floor() → int
- Returns the greatest integer no greater than
this
. [...] - floorToDouble() → double
- Returns the greatest double integer value no greater than
this
. [...] - remainder(num other) → num
- Returns the remainder of the truncating division of
this
by other
. [...] - round() → int
- Returns the integer closest to
this
. [...] - roundToDouble() → double
- Returns the double integer value closest to
this
. [...] - toDouble() → double
- Return this num as a double. [...]
- toInt() → int
- Truncates this num to an integer and returns the result as an int.
- toString() → String
override
- Returns the shortest string that correctly represent the input number. [...]
- toStringAsExponential([int fractionDigits ]) → String
- Returns an exponential string-representation of
this
. [...] - toStringAsFixed(int fractionDigits) → String
- Returns a decimal-point string-representation of
this
. [...] - toStringAsPrecision(int precision) → String
- Converts
this
to a double and returns a string representation with exactly precision
significant digits. [...] - truncate() → int
- Returns the integer obtained by discarding any fractional digits from
this
. [...] - truncateToDouble() → double
- Returns the double integer value obtained by discarding any fractional digits from the double value of
this
. [...] - noSuchMethod(Invocation invocation) → dynamic
inherited
- Invoked when a non-existent method or property is accessed. [...]
Operators
- operator %(num other) → num
- Euclidean modulo operator. [...]
- operator *(num other) → num
- Multiplication operator.
- operator +(num other) → num
- Addition operator.
- operator -(num other) → num
- Subtraction operator.
- operator /(num other) → double
- Division operator.
- operator <(num other) → bool
- Relational less than operator.
- operator <=(num other) → bool
- Relational less than or equal operator.
- operator ==(Object other) → bool
override
- Test whether this value is numerically equal to
other
. [...] - operator >(num other) → bool
- Relational greater than operator.
- operator >=(num other) → bool
- Relational greater than or equal operator.
- operator unary-() → num
- Negate operator.
- operator ~/(num other) → int
- Truncating division operator. [...]
Static Methods
- parse(String input, [ num onError(String input) ]) → num
- Parses a string containing a number literal into a number. [...]
- tryParse(String input) → num
- Parses a string containing a number literal into a number. [...]