Number class abstract

Implemented types
Implementers

Constructors

Number()

Properties

hashCode int
Returns a hash code for a numerical value.
no setteroverride
isInfinite bool
True if the number is infinite; otherwise, false.
no setter
isNaN bool
True if the number is not a number; otherwise, false.
no setter
isNegative bool
True if the number is negative; otherwise, false.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
sign Integer
Returns minus one, zero or plus one depending on the sign and numerical value of the number.
no setter

Methods

abs() Number
Returns the absolute value of this num.
ceil() Integer
Returns the least integer no smaller than this.
compareTo(Number other) int
Compares this to other.
override
floor() Integer
Returns the greatest integer no greater than this.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
remainder(Number other) Number
Returns the remainder of the truncating division of this by other.
round() Integer
Returns the integer closest to this.
roundWithPrecision(int precision, [RoundingMode mode = RoundingMode.nearestEven]) Number
Returns number rounded according to precision and RoundingMode.
toInt() int
Truncates this Number to an integer and returns the result as an int. */
toInteger() Integer
Truncates this Number to an integer and returns the result as an Integer.
toString() String
Returns the shortest string that correctly represent the input number.
override
toStringAsExponential([int? fractionDigits]) String
Returns an exponential string-representation of this.
toStringAsFixed(int fractionDigits) String
Returns a decimal-point string-representation of this. Converts this to a Decimal before computing the string representation. If the absolute value of this is greater or equal to 10^21 then this methods returns an exponential representation computed by this.toStringAsExponential(). Otherwise the result is the closest string representation with exactly fractionDigits digits after the decimal point. If fractionDigits equals 0 then the decimal point is omitted.
toStringAsPrecision(int precision) String
Converts this to a decimal and returns a string representation with exactly precision significant digits.
truncate() Integer
Returns the integer obtained by discarding any fractional digits from this.

Operators

operator %(Number other) Number
Euclidean modulo operator.
operator *(Number other) Number
Multiplication operator.
operator +(Number other) Number
Addition operator.
operator -(Number other) Number
Subtraction operator.
operator /(Number other) Decimal
Division operator.
operator <(Number other) bool
Relational less than operator.
operator <=(Number other) bool
Relational less than or equal operator.
operator ==(Object other) bool
Test whether this value is numerically equal to other.
override
operator >(Number other) bool
Relational greater than operator.
operator >=(Number other) bool
Relational greater than or equal operator.
operator unary-() Number
Negate operator.
operator ~/(Number other) Integer
Truncating division operator.

Static Methods

parse(String input) Number
Parses a string containing a number literal into a number. The method first tries to read the input as integer (similar to int.parse without a radix). If that fails, it tries to parse the input as a decimal (similar to Decimal.parse). If that fails too, it throws FormatException.