number library

The quantity package accepts both Dart's num types and the Numbers defined by this number library as quantity values and for quantity operations.

The classes in this library can be used to model quantities having values with arbitrary precision as well as imaginary or complex numbers. It is independent of the quantity classes and can be used in a purely mathematical context.

Classes

Binary
Represents an integer as a binary number.
Complex
Complex numbers have both a real and an imaginary part.
Digit
Represents a digit in four bits of a single byte. This wastes four bits but that's a decent trade-off for simplicity and better anyway than the 4+ bytes allocated for a regular int.
Double
Wraps Dart's core double type, so that it can share a common base type with other Numbers.
Fraction
A convenient way to represent fractional numbers.
Hexadecimal
Represents an integer as a hexadecimal number.
Imaginary
Represents an imaginary number, defined as a number whose square is negative one.
Integer
Wraps Dart's core int type, so that it can share a common base type with other Numbers.
Number
The abstract base class for all Number types.
Octal
Represents an integer as an octal number.
Precise
Precise represents an arbitrary precision number.
Real
Provides a common handle for all Real Numbers.

Functions

erf(double x) double
Approximate solution for the error function of x.
hashObjects(Iterable<Object> objects) int
Generates a unique hash for a set of objects.
numberToNum(Number number) num
Converts a Number to the equivalent num.
numToNumber(num value) Number
Converts a num value to associated Number object (Integer for ints and doubles that have an integer value, Double for other doubles).
objToNumber(Object object) Number
Converts an object to a Number. The object must be either a num or Number, otherwise an Exception is thrown.

Exceptions / Errors

NumberException
The base class for all exceptions thrown in relation to numbers.