FLUTTER ECOSYSTEM

onepub-dev/fixed

固定精度数値の Dart 実装。

固定 のプロジェクト画像
Stars
12
Forks
7
最終プッシュ(UTC)
2026/08/16
プロジェクト状態
公開中
OnePub GitHub avatar
GITHUB Organization

OnePub ↗

言語Dart

このリポジトリが公開するパッケージ

使用している依存関係

依存関係一覧 5 件

元の README

以下は英語原文のスナップショットです。最新版は GitHub をご覧ください。

README を開く / 閉じる

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.

Sponsors

Fixed is sponsored by OnePub, the Dart private package repository.

OnePub

You can create a Fixed instance from a number sources

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

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

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

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

Full documentation can be found here.