quantity_core library

Core library containing only core dimensions, units, numbers and quantity engine classes.

Classes

Binary
Represents an integer as a binary number.
Complex
Complex numbers have both a real and an imaginary part.
Decimal
A number that can be exactly written with a finite number of digits in the decimal system.
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.
Dimensions
The Dimensions class represents the dimensions of a physical quantity.
Double
Wraps Dart's core double type, so that it can share a common base type with other Numbers.
EngineeringFormatSI
A version of scientific notation in which the exponent of ten must be divisible by three (e.g., 123.345 x 10^3).
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.
MiscQuantity
A MiscQuantity is a general (miscellaneous) Quantity having arbitrary dimensions (including possibly the same dimensions as a named Quantity subclass). MiscQuantity objects may be used, for example, in less common domains or as intermediate results in equations.
Number
The abstract base class for all Number types.
NumberFormatSI
NumberFormatSI implements the International System of Units (SI) style conventions for displaying values of quantities. Specifically:
Octal
Represents an integer as an octal number.
Precise
Precise represents an arbitrary precision number.
Quantity
The abstract base class for all quantities. The Quantity class represents the value of a physical quantity and its associated dimensions. It provides methods for constructing and getting the quantity's value in arbitrary units, methods for mathematical manipulation and comparison and optional features such as arbitrary precision and uncertainty.
Real
Provides a common handle for all Real Numbers.
ScientificFormatSI
Formats a number as a single integer digit, followed by decimal digits and raised to a power of 10 (e.g., 1.2345 x 10^3).

Enums

UncertaintyFormat
Whether and how to display a quantity's uncertainty (e.g., compact is 32.324(12), not compact is (32.324 +/- 0.012)).

Mixins

Units
A unit is a particular physical quantity, defined and adopted by convention, with which other particular quantities of the same kind (dimensions) are compared to express their value.

Extensions

BigIntExt on BigInt
Extensions on BigInt.
IntExt on int
Extensions on int.
RationalExt on Rational
Extensions on Rational.

Constants

expUnicodeMap → const Map<String, String>
Maps a digit, decimal point or minus sign string to a unicode exponent character.

Properties

allQuantityTypes Iterable<Type>
Returns an iterable of Type objects representing all of the quantity types supported by this library (for example, Angle, Length, etc.).
no setter
dimensionsToTypeMap Map<Dimensions, Type>
no setter
dynamicQuantityTyping bool
Dynamic quantity typing may be turned off for increased efficiency. If false, the result of operations where dimensions may change will be MiscQuantity type objects.
getter/setter pair
logger ↔ Logger
Logger for use across entire library
getter/setter pair
siRegistryTrigger ↔ void Function()?
Trigger to initialize/register SI quantities. Populated by register_si.dart when loaded.
getter/setter pair

Functions

areWithin(Quantity q1, Quantity q2, Quantity tolerance) bool
Returns whether or not the magnitude of the difference between two quantities is less than or equal to the specified tolerance.
condenseUnicodeSequences(String? input) String?
createTypedQuantityInstance(Type t, dynamic value, Units? units, {double uncert = 0.0, Dimensions? dimensions}) Quantity
Creates an instance of a typed quantity of type t having the specified value in units.
erf(double x) double
Approximate solution for the error function of x.
getQuantitySynonyms(Type type) List<String>
Returns all registered synonym names for a given quantity type.
getRegisteredQuantityType(Dimensions dimensions) Type?
Returns the quantity type associated with dimensions, if registered.
getRegisteredTypeByName(String typeName) Type?
Resolves a dynamic Type from its String typeName representation by searching the registered physical quantity subclasses and synonyms.
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.
registerQuantitySynonym(String synonymName, Type targetType) → void
Registers a synonym name for a target physical quantity type.
registerQuantityType(Type type, Dimensions dimensions, Function instantiator) → void
Registers a constructor function for a physical quantity type.
siBaseQuantity(Quantity q) bool
Returns whether or not q is one of the seven SI base quantities.
siDerivedQuantity(Quantity q) bool
Returns whether or not q is a derived quantity (as opposed to one of the seven base SI quantities).
unicodeExponent(num exp) String
Returns the unicode symbols that represent an exponent.

Exceptions / Errors

DimensionsException
This Exception is thrown when an attempt is made to perform an operation on a Quantity having unexpected or illegal dimensions.
ImmutableQuantityException
This Exception is thrown when an attempt is made to modify an immutable Quantity object (for example through its setMKS method).
NumberException
The base class for all exceptions thrown in relation to numbers.
QuantityException
The base class for all exceptions thrown in relation to quantities.