Dart API Referencedart:coredouble

double abstract class

Representation of Dart doubles containing double specific constants and operations and specializations of operations inherited from num.

The double type is contagious. Operations on doubles return double results.

abstract class double extends num {
  static const double NAN = 0.0 / 0.0;
  static const double INFINITY = 1.0 / 0.0;
  static const double NEGATIVE_INFINITY = -INFINITY;
  static const double MIN_POSITIVE = 5e-324;
  static const double MAX_FINITE = 1.7976931348623157e+308;

  /** Return the remainder from dividing this [double] by [other]. */
  abstract double remainder(num other);

  /** Addition operator. */
  abstract double operator +(num other);

  /** Subtraction operator. */
  abstract double operator -(num other);

  /** Multiplication operator. */
  abstract double operator *(num other);

  /** Euclidean modulo operator. */
  abstract double operator %(num other);

  /** Division operator. */
  abstract double operator /(num other);

  /**
   * Truncating division operator.
   *
   * The result of the truncating division [:a ~/ b:] is equivalent to
   * [:(a / b).truncate():].
   */
  abstract double operator ~/(num other);

  /** Negate operator. */
  abstract double operator -();

  /** Returns the absolute value of this [double]. */
  abstract double abs();

  /**
   * Returns the integer value closest to this [double].
   *
   * Rounds away from zero when there is no closest integer:
   *  [:(3.5).round() == 4:] and [:(-3.5).round() == -4:].
   */
  abstract double round();

  /** Returns the greatest integer value no greater than this [double]. */
  abstract double floor();

  /** Returns the least integer value that is no smaller than this [double]. */
  abstract double ceil();

  /**
   * Returns the integer value obtained by discarding any fractional
   * digits from this [double].
   */
  abstract double truncate();

  /**
   * Provide a representation of this [double] value.
   *
   * The representation is a number literal such that the closest double value
   * to the representation's mathematical value is this [double].
   *
   * Returns "NaN" for the Not-a-Number value.
   * Returns "Infinity" and "-Infinity" for positive and negative Infinity.
   * Returns "-0.0" for negative zero.
   *
   * It should always be the case that if [:d:] is a [double], then
   * [:d == double.parse(d.toString()):].
   */
  abstract String toString();

  /**
   * Parse [source] as an double literal and return its value.
   *
   * Accepts the same format as double literals:
   *   [: ['+'|'-'] [digit* '.'] digit+ [('e'|'E') ['+'|'-'] digit+] :]
   *
   * Also recognizes "NaN", "Infinity" and "-Infinity" as inputs and
   * returns the corresponding double value.
   *
   * Throws a [FormatException] if [source] is not a valid double literal.
   */
  external static double parse(String source);
}

Extends

num > double

Static Properties

const double INFINITY #

static const double INFINITY = 1.0 / 0.0;

const double MAX_FINITE #

static const double MAX_FINITE = 1.7976931348623157e+308;

const double MIN_POSITIVE #

static const double MIN_POSITIVE = 5e-324;

const double NAN #

static const double NAN = 0.0 / 0.0;

const double NEGATIVE_INFINITY #

static const double NEGATIVE_INFINITY = -INFINITY;

Static Methods

double parse(String source) #

Parse source as an double literal and return its value.

Accepts the same format as double literals: ['+'|'-'] [digit* '.'] digit+ [('e'|'E') ['+'|'-'] digit+]

Also recognizes "NaN", "Infinity" and "-Infinity" as inputs and returns the corresponding double value.

Throws a FormatException if source is not a valid double literal.

external static double parse(String source);

Properties

final bool isInfinite #

inherited from num
bool get isInfinite;

final bool isNaN #

inherited from num
bool get isNaN;

final bool isNegative #

inherited from num
bool get isNegative;

Operators

abstract double operator +(num other) #

Addition operator.

abstract double operator -() #

Negate operator.

abstract double operator -(num other) #

Subtraction operator.

abstract double operator *(num other) #

Multiplication operator.

abstract double operator /(num other) #

Division operator.

abstract double operator ~/(num other) #

Truncating division operator.

The result of the truncating division a ~/ b is equivalent to (a / b).truncate().

abstract double operator %(num other) #

Euclidean modulo operator.

bool operator <(num other) #

inherited from num

Relational less than operator.

bool operator <(num other);

bool operator <=(num other) #

inherited from num

Relational less than or equal operator.

bool operator <=(num other);

bool operator >(num other) #

inherited from num

Relational greater than operator.

bool operator >(num other);

bool operator >=(num other) #

inherited from num

Relational greater than or equal operator.

bool operator >=(num other);

Methods

abstract double abs() #

Returns the absolute value of this double.

abstract double ceil() #

Returns the least integer value that is no smaller than this double.

abstract int compareTo(Comparable other) #

inherited from Comparable

Compares this object to another Comparable

Returns a value like a Comparator when comparing this to other.

May throw an ArgumentError if other is of a type that is not comparable to this.

abstract double floor() #

Returns the greatest integer value no greater than this double.

abstract double remainder(num other) #

Return the remainder from dividing this double by other.

abstract double round() #

Returns the integer value closest to this double.

Rounds away from zero when there is no closest integer: (3.5).round() == 4 and (-3.5).round() == -4.

double toDouble() #

inherited from num

Return this num as a double.

If the number is not representable as a double, an approximation is returned. For numerically large integers, the approximation may be infinite.

double toDouble();

int toInt() #

inherited from num

Truncates this num to an integer and returns the result as an int.

int toInt();

String toRadixString(int radix) #

inherited from num

Converts a num to a string representation in the given radix.

The num in converted to an int using toInt. That int is then converted to a string representation with the given radix. In the string representation, lower-case letters are used for digits above '9'.

The radix argument must be an integer between 2 and 36.

String toRadixString(int radix);

abstract String toString() #

Provide a representation of this double value.

The representation is a number literal such that the closest double value to the representation's mathematical value is this double.

Returns "NaN" for the Not-a-Number value. Returns "Infinity" and "-Infinity" for positive and negative Infinity. Returns "-0.0" for negative zero.

It should always be the case that if d is a double, then d == double.parse(d.toString()).

String toStringAsExponential(int fractionDigits) #

inherited from num

Converts a num to a string in decimal exponential notation with fractionDigits digits after the decimal point.

String toStringAsExponential(int fractionDigits);

String toStringAsFixed(int fractionDigits) #

inherited from num

Converts a num to a string representation with fractionDigits digits after the decimal point.

String toStringAsFixed(int fractionDigits);

String toStringAsPrecision(int precision) #

inherited from num

Converts a num to a string representation with precision significant digits.

String toStringAsPrecision(int precision);

abstract double truncate() #

Returns the integer value obtained by discarding any fractional digits from this double.