Dart: Math Constants

Another small feature of the dart math library are math constants. Just import the following line:

import 'dart:math' as math;

This are all the math constants the library knows:

E (Base of the natural logarithms)

print(math.E);

Result: 2.718281828459045

PI

print(math.PI);

Result: 3.141592653589793

SQRT2 (Square root of 2)

print(math.SQRT2);

Result: 1.4142135623730951

LN10 (Natural logarithm of 10)

print(math.LN10);

Result: 2.302585092994046

LN2 (Natural logarithm of 2)

print(math.LN2);

Result: 0.6931471805599453

LOG10E (Base -10 logarithm of [E])

print(math.LOG10E);

Result: 0.4342944819032518

LOG2E (Base -2 logarithm of [E])

print(math.LOG2E);

Result: 1.4426950408889634

SQRT1_2 (Square root of 0.5)

print(math.SQRT1_2);

Result: 0.7071067811865476

Yannick Signer