Package: effect
Module: BigDecimal
Computes a rounded BigDecimal at the given scale with the specified rounding mode.
When to use
Use to round a decimal at a requested scale with an explicit rounding mode.
Example (Rounding decimals)
import { BigDecimal } from "effect"
import * as assert from "node:assert"
assert.deepStrictEqual(
BigDecimal.round(BigDecimal.fromStringUnsafe("145"), { mode: "from-zero", scale: -1 }),
BigDecimal.fromStringUnsafe("150")
)
assert.deepStrictEqual(
BigDecimal.round(BigDecimal.fromStringUnsafe("-14.5")),
BigDecimal.fromStringUnsafe("-15")
)
See
ceil for fixed rounding toward positive infinityfloor for fixed rounding toward negative infinitytruncate for fixed rounding toward zeroSignature
declare const round: { (options: { scale?: number; mode?: RoundingMode; }): (self: BigDecimal) => BigDecimal; (n: BigDecimal, options?: { scale?: number; mode?: RoundingMode; }): BigDecimal; }
Since v3.16.0