Hyperlinkv0.8.0-beta.28

BigDecimal

BigDecimal.multiplyconsteffect/BigDecimal.ts:378
(that: BigDecimal): (self: BigDecimal) => BigDecimal
(self: BigDecimal, that: BigDecimal): BigDecimal

Provides a multiplication operation on BigDecimals.

When to use

Use to multiply two BigDecimal values.

Example (Multiplying decimals)

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

assert.deepStrictEqual(
  BigDecimal.multiply(BigDecimal.fromStringUnsafe("2"), BigDecimal.fromStringUnsafe("3")),
  BigDecimal.fromStringUnsafe("6")
)
export const multiply: {
  (that: BigDecimal): (self: BigDecimal) => BigDecimal
  (self: BigDecimal, that: BigDecimal): BigDecimal
} = dual(2, (self: BigDecimal, that: BigDecimal): BigDecimal => {
  if (that.value === bigint0 || self.value === bigint0) {
    return zero
  }

  return make(self.value * that.value, self.scale + that.scale)
})
Referenced by 1 symbols