effect-io-ai

Package: effect
Module: BigDecimal

BigDecimal.sumAll

Takes an Iterable of BigDecimals and returns their sum as a single BigDecimal.

When to use

Use when you need to aggregate decimal quantities with decimal precision instead of converting through JavaScript numbers.

Example (Adding multiple decimals)

import { BigDecimal } from "effect"
import * as assert from "node:assert"

assert.deepStrictEqual(
  BigDecimal.sumAll([BigDecimal.fromStringUnsafe("2"), BigDecimal.fromStringUnsafe("3"), BigDecimal.fromStringUnsafe("4")]),
  BigDecimal.fromStringUnsafe("9")
)

See

Signature

declare const sumAll: (collection: Iterable<BigDecimal>) => BigDecimal

Source

Since v3.16.0