num classsealed
An integer or floating-point number.
It is a compile-time error for any type other thanint ordoubleto attempt to extend or implementnum.
See also:
- int: An integer number.
- double: A double-precision floating point number.
- Numbers inA 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 andnumerical value of this number.no setter
- toJS→JSNumber
Available onnum, provided by theNumToJSExtension extension
Converts thisnum to aJSNumber.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(
numlowerLimit,numupperLimit)→num - Returns thisnum clamped to be in the range
lowerLimit-upperLimit. - compareTo(
numother)→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(
Invocationinvocation)→ dynamic - Invoked when a nonexistent method or property is accessed.inherited
- remainder(
numother)→num - The remainder of the truncating division of
thisbyother. - round(
)→int - The integer closest to this number.
- roundToDouble(
)→double - The double integer value closest to this value.
- toDouble(
)→double - This number as adouble.
- toInt(
)→int - Truncates thisnum to an integer and returns the result as anint.
- toString(
)→String - The shortest string that correctly represents this number.override
- toStringAsExponential(
[int?fractionDigits])→String - An exponential string-representation of this number.
- toStringAsFixed(
intfractionDigits)→String - A decimal-point string-representation of this number.
- toStringAsPrecision(
intprecision)→String - A string representation with
precisionsignificant digits. - truncate(
)→int - The integer obtained by discarding any fractional digits from
this. - truncateToDouble(
)→double - Returns the double integer value obtained by discarding any fractionaldigits from the double value of
this.
Operators
- operator %(
numother)→num - Euclidean modulo of this number by
other. - operator *(
numother)→num - Multiplies this number by
other. - operator +(
numother)→num - Adds
otherto this number. - operator -(
numother)→num - Subtracts
otherfrom this number. - operator /(
numother)→double - Divides this number by
other. - operator<(
numother)→bool - Whether this number is numerically smaller than
other. - operator<=(
numother)→bool - Whether this number is numerically smaller than or equal to
other. - operator ==(
Objectother)→bool - Test whether this value is numerically equal to
other.override - operator >(
numother)→bool - Whether this number is numerically greater than
other. - operator >=(
numother)→bool - Whether this number is numerically greater than or equal to
other. - operator unary-(
)→num - The negation of this value.
- operator ~/(
numother)→int - Truncating division operator.