#high-precision #decimal #math #arithmetic-operations #place #wad #precise

decimal-wad

Math for preserving precision floats up to 18 decimal places

9 releases

0.1.9 May 31, 2023
0.1.8 Oct 27, 2022
0.1.7 Aug 22, 2022
0.1.6 Jul 20, 2022
0.1.2 Nov 30, 2021

#1359 in Algorithms

Download history 50/week @ 2024-11-16 16/week @ 2024-11-23 32/week @ 2024-11-30 64/week @ 2024-12-07 319/week @ 2024-12-14 14/week @ 2024-12-21 25/week @ 2024-12-28 95/week @ 2025-01-04 169/week @ 2025-01-11 49/week @ 2025-01-18 55/week @ 2025-01-25 56/week @ 2025-02-01 96/week @ 2025-02-08 107/week @ 2025-02-15 43/week @ 2025-02-22 79/week @ 2025-03-01

340 downloads per month

MIT license

23KB
673 lines

Decimal WAD

Math for preserving precision floats which are limited to be at most u64::MAX.

  • Decimals are internally scaled by a WAD (10^18) to preserve precision up to 18 decimal places.
  • Decimals are sized to support both serialization and precise math for the full range of unsigned 64-bit integers.
  • The underlying representation of decimals is a u192 rather than u256 to reduce compute cost while losing support for arithmetic operations at the high end of u64 range.
  • Rates are sized to support both serialization and precise math for the full range of unsigned 8-bit integers.
  • The underlying representation of rates is a u128 rather than u192 to reduce compute cost while losing support for arithmetic operations at the high end of u8 range.

Dependencies

~240KB