fixed 3.0.0 icon indicating copy to clipboard operation
fixed: ^3.0.0 copied to clipboard

Fixed scale decimal numbers with mathematical operations, formatting and parsing.

The Fixed package allows you to store and perform math on decimal numbers with a fixed scale (fixed no. of decimal places).

All amounts are stored as BigInts to allow precision math to be performed.

The features of Fixed are:

  • Fixed uses a selectable fixed scale (no. of decimal places)
  • Fixed provides a builtin formatter and parser Fixed.format(pattern)
  • Full set of mathematical opertors.
  • Fixed includes a convenience method Fixed.formatIntl(locale) which formats the number with the provided locale or the default locale if not provided.

You can create a Fixed instance from a number sources

var t1 = Fixed.fromNum(1); /// == 1.00
var t2 = Fixed.fromNum(1, scale: 3); /// == 1.000

var add = t1 + 10;
var multiply = t1 * t2;

var t3 = Fixed.parse("1.23356"); // == 1.23356, scale: 5

if (t1 == t2) // true
{
    print(t1.format('0.##')); // '1.00'
}

Full documentation can be found here.

4
likes
140
pub points
77%
popularity

Publisher

verified publisher icononepub.dev

Fixed scale decimal numbers with mathematical operations, formatting and parsing.

Repository (GitHub)

Documentation

Documentation
API reference

License

Icon for licenses.MIT (LICENSE)

Dependencies

decimal, intl, meta

More

Packages that depend on fixed