effect-io-ai

Package: effect
Module: BigDecimal

BigDecimal.floor

Computes the floor of a BigDecimal at the given scale.

When to use

Use to round a decimal toward negative infinity at a requested scale.

Example (Rounding decimals down)

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

assert.deepStrictEqual(
  BigDecimal.floor(BigDecimal.fromStringUnsafe("145"), -1),
  BigDecimal.fromStringUnsafe("140")
)
assert.deepStrictEqual(
  BigDecimal.floor(BigDecimal.fromStringUnsafe("-14.5")),
  BigDecimal.fromStringUnsafe("-15")
)

See

Signature

declare const floor: { (scale: number): (self: BigDecimal) => BigDecimal; (self: BigDecimal, scale?: number): BigDecimal; }

Source

Since v3.16.0