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
- Whether the number is finite. [...]
- isInfinite → bool read-only
- Whether the number is positive infinity or negative infinity.
- isNaN → bool read-only
- Whether the number is the double Not-a-Number value.
- isNegative → bool read-only
- Whether if the number is negative. [...]
- runtimeType → Type read-only, inherited
- A representation of the runtime type of the object.
- sign → num read-only
- Negative one, zero or positive one depending on the sign and numerical value of the number. [...]
Methods
- abs(
) → num - The absolute value of this number. [...]
- ceil(
) → int - 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 - The greatest integer no greater than this number. [...]
- floorToDouble(
) → double - Returns the greatest double integer value no greater than
this
. [...] - noSuchMethod(
Invocation invocation) → dynamic inherited - Invoked when a non-existent method or property is accessed. [...]
- remainder(
num other) → num - The remainder of the truncating division of
this
byother
. [...] - round(
) → int - The integer closest to this number. [...]
- roundToDouble(
) → double - The double integer value closest to this value. [...]
- toDouble(
) → double - This number as a double. [...]
- toInt(
) → int - Truncates this num to an integer and returns the result as an int. [...]
- toString(
) → String override - The shortest string that correctly represent this number number. [...]
- toStringAsExponential(
[int? fractionDigits]) → String - An exponential string-representation of this number. [...]
- toStringAsFixed(
int fractionDigits) → String - A decimal-point string-representation of this number. [...]
- toStringAsPrecision(
int precision) → String - A string representation with
precision
significant digits. [...] - truncate(
) → int - 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
. [...]
Operators
- operator %(
num other) → num - Euclidean modulo of this number by
other
. [...] - operator *(
num other) → num - Multiplies this number by
other
. [...] - operator +(
num other) → num - Adds
other
to this number. [...] - operator -(
num other) → num - Subtracts
other
from this number. [...] - operator /(
num other) → double - Divides this number by
other
. - operator <(
num other) → bool - Whether
other
is numerically smaller than this number. [...] - operator <=(
num other) → bool - Whether
other
is numerically smaller than or equal to this number. [...] - operator ==(
Object other) → bool override - Test whether this value is numerically equal to
other
. [...] - operator >(
num other) → bool - Whether
other
is numerically greater than this number. [...] - operator >=(
num other) → bool - Whether
other
is numerically greater than or equal to this number. [...] - operator unary-(
) → num - The negation of this value. [...]
- 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. [...]
© 2012 the Dart project authors
Licensed under the Creative Commons Attribution-ShareAlike License v4.0.
https://api.dart.dev/stable/2.13.0/dart-core/num-class.html