num class sealed
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
.
See also:
- int: An integer number.
- double: A double-precision floating point number.
- Numbers in A tour of the Dart language.
- Implemented types
- Implementers
- Available extensions
Properties
- hashCode โ int
-
Returns a hash code for a numerical value.
no setteroverride
- isFinite โ bool
-
Whether this number is finite.
no setter
- isInfinite โ bool
-
Whether this number is positive infinity or negative infinity.
no setter
- isNaN โ bool
-
Whether this number is a Not-a-Number value.
no setter
- isNegative โ bool
-
Whether this number is negative.
no setter
- runtimeType โ Type
-
A representation of the runtime type of the object.
no setterinherited
- sign โ num
-
Negative one, zero or positive one depending on the sign and
numerical value of this number.
no setter
- toJS โ JSNumber
-
Available on num, provided by the NumToJSExtension extension
Converts this num to a JSNumber.no setter
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 -
Compares this to
other
.override -
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 -
Invoked when a nonexistent method or property is accessed.
inherited
-
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 -
The shortest string that correctly represents this number.
override
-
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 this number is numerically smaller than
other
. -
operator <=(
num other) โ bool -
Whether this number is numerically smaller than or equal to
other
. -
operator ==(
Object other) โ bool -
Test whether this value is numerically equal to
other
.override -
operator >(
num other) โ bool -
Whether this number is numerically greater than
other
. -
operator >=(
num other) โ bool -
Whether this number is numerically greater than or equal to
other
. -
operator unary-(
) โ num - The negation of this value.
-
operator ~/(
num other) โ int - Truncating division operator.