Dart API Referencedart:coreMath

Math Class

Static Methods

Code double acos(num x) #

static double acos(num x) native;

Code double asin(num x) #

static double asin(num x) native;

Code double atan(num x) #

static double atan(num x) native;

Code double atan2(num a, num b) #

Returns the arc tangent of a/ b with sign according to quadrant.

static double atan2(num a, num b) native;

Code double cos(num x) #

static double cos(num x) native;

Code double exp(num x) #

static double exp(num x) native;

Code double log(num x) #

static double log(num x) native;

Code num max(num a, num b) #

static num max(num a, num b) native 'return (a >= b) ? a : b;';

Code num min(num a, num b) #

static num min(num a, num b) native '''if (a == b) return a;
if (a < b) {
  if (isNaN(b)) return b;
  else return a;
}
if (isNaN(a)) return a;
else return b;''';

Code double parseDouble(String str) #

Parses a String representation of a double, and returns a double. Throws a BadNumberFormatException if str cannot be parsed as a double.

static double parseDouble(String str) native '''var ret = parseFloat(str);
if (isNaN(ret) && str != 'NaN') \$throw(new BadNumberFormatException(str));
return ret;''' { throw new BadNumberFormatException(""); }

Code int parseInt(String str) #

Parses a String representation of an int, and returns an int. Throws a BadNumberFormatException if str cannot be parsed as an int.

static int parseInt(String str) native '''
var match = /^\\s*[+-]?(?:(0[xX][abcdefABCDEF0-9]+)|\\d+)\\s*\$/.exec(str);
if (!match) \$throw(new BadNumberFormatException(str));
var isHex = !!match[1];
var ret = parseInt(str, isHex ? 16 : 10);
if (isNaN(ret)) \$throw(new BadNumberFormatException(str));
return ret;''' { throw new BadNumberFormatException(""); }

Code num pow(num x, num exponent) #

If the exponent is an integer the result is of the same type as x. Otherwise it is a double.

static num pow(num x, num exponent) native;

Code double random() #

Returns a random double greater than or equal to 0.0 and less than 1.0.

static double random() native;

Code double sin(num x) #

static double sin(num x) native;

Code double sqrt(num x) #

static double sqrt(num x) native;

Code double tan(num x) #

static double tan(num x) native;

Static Fields

Code final double E #

Base of the natural logarithms.

static final double E = 2.718281828459045;

Code final double LN10 #

Natural logarithm of 10.

static final double LN10 =  2.302585092994046;

Code final double LN2 #

Natural logarithm of 2.

static final double LN2 =  0.6931471805599453;

Code final double LOG10E #

Base-10 logarithm of E.

static final double LOG10E = 0.4342944819032518;

Code final double LOG2E #

Base-2 logarithm of E.

static final double LOG2E = 1.4426950408889634;

Code final double PI #

The PI constant.

static final double PI = 3.1415926535897932;

Code final double SQRT1_2 #

Square root of 1/2.

static final double SQRT1_2 = 0.7071067811865476;

Code final double SQRT2 #

Square root of 2.

static final double SQRT2 = 1.4142135623730951;