num class - dart:core library (original) (raw)
An integer or floating-point number.
It is a compile-time error for any type other than int or doubleto attempt to extend or implement num
.
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
Returns a hash code for a numerical value.
no setteroverride
Whether this number is finite.
no setter
Whether this number is positive infinity or negative infinity.
no setter
Whether this number is a Not-a-Number value.
no setter
Whether this number is negative.
no setter
A representation of the runtime type of the object.
no setterinherited
Negative one, zero or positive one depending on the sign and numerical value of this number.
no setter
Available on num, provided by the NumToJSExtension extension
Converts this num to a JSNumber.
no setter
Methods
The absolute value of this number.
The least integer no smaller than this
.
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
.
Compares this to other
.
override
The greatest integer no greater than this number.
Returns the greatest double integer value no greater than this
.
noSuchMethod(Invocation invocation)→ dynamic
Invoked when a nonexistent method or property is accessed.
inherited
The remainder of the truncating division of this
by other
.
The integer closest to this number.
The double integer value closest to this value.
This number as a double.
Truncates this num to an integer and returns the result as an int.
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.
The integer obtained by discarding any fractional digits from this
.
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
.
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.
Parses a string containing a number literal into a number.