Hyperlinkv0.8.0-beta.28

BigDecimal

BigDecimal.negateconsteffect/BigDecimal.ts:1057
(n: BigDecimal): BigDecimal

Provides a negate operation on BigDecimals.

When to use

Use to flip the sign of a BigDecimal.

Example (Negating decimals)

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

assert.deepStrictEqual(BigDecimal.negate(BigDecimal.fromStringUnsafe("3")), BigDecimal.fromStringUnsafe("-3"))
assert.deepStrictEqual(BigDecimal.negate(BigDecimal.fromStringUnsafe("-6")), BigDecimal.fromStringUnsafe("6"))
math
export const negate = (n: BigDecimal): BigDecimal => make(-n.value, n.scale)