(options: { scale?: number; mode?: RoundingMode }): (
self: BigDecimal
) => BigDecimal
(
n: BigDecimal,
options?: { scale?: number; mode?: RoundingMode }
): BigDecimalComputes 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")
)export const const round: {
(options: {
scale?: number
mode?: RoundingMode
}): (self: BigDecimal) => BigDecimal
(
n: BigDecimal,
options?: {
scale?: number
mode?: RoundingMode
}
): 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")
)
round: {
(options: { scale?: number; mode?: RoundingMode }options: { scale?: number | undefinedscale?: number; mode?: RoundingModemode?: type RoundingMode =
| "ceil"
| "floor"
| "to-zero"
| "from-zero"
| "half-ceil"
| "half-floor"
| "half-to-zero"
| "half-from-zero"
| "half-even"
| "half-odd"
Rounding modes for BigDecimal.
When to use
Use with round to choose how discarded digits affect a BigDecimal
rounded to a target scale.
Details
ceil: round towards positive infinity
floor: round towards negative infinity
to-zero: round towards zero
from-zero: round away from zero
half-ceil: round to the nearest neighbor; if equidistant round towards positive infinity
half-floor: round to the nearest neighbor; if equidistant round towards negative infinity
half-to-zero: round to the nearest neighbor; if equidistant round towards zero
half-from-zero: round to the nearest neighbor; if equidistant round away from zero
half-even: round to the nearest neighbor; if equidistant round to the neighbor with an even digit
half-odd: round to the nearest neighbor; if equidistant round to the neighbor with an odd digit
RoundingMode }): (self: BigDecimal(parameter) self: {
value: bigint;
scale: number;
normalized: BigDecimal;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
self: BigDecimal) => BigDecimal
(n: BigDecimal(parameter) n: {
value: bigint;
scale: number;
normalized: BigDecimal;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
n: BigDecimal, options: { scale?: number; mode?: RoundingMode }options?: { scale?: number | undefinedscale?: number; mode?: RoundingModemode?: type RoundingMode =
| "ceil"
| "floor"
| "to-zero"
| "from-zero"
| "half-ceil"
| "half-floor"
| "half-to-zero"
| "half-from-zero"
| "half-even"
| "half-odd"
Rounding modes for BigDecimal.
When to use
Use with round to choose how discarded digits affect a BigDecimal
rounded to a target scale.
Details
ceil: round towards positive infinity
floor: round towards negative infinity
to-zero: round towards zero
from-zero: round away from zero
half-ceil: round to the nearest neighbor; if equidistant round towards positive infinity
half-floor: round to the nearest neighbor; if equidistant round towards negative infinity
half-to-zero: round to the nearest neighbor; if equidistant round towards zero
half-from-zero: round to the nearest neighbor; if equidistant round away from zero
half-even: round to the nearest neighbor; if equidistant round to the neighbor with an even digit
half-odd: round to the nearest neighbor; if equidistant round to the neighbor with an odd digit
RoundingMode }): BigDecimal
} = dual<(...args: Array<any>) => any, (self: BigDecimal, options?: {
scale?: number;
mode?: RoundingMode;
}) => BigDecimal>(isDataFirst: (args: IArguments) => boolean, body: (self: BigDecimal, options?: {
scale?: number;
mode?: RoundingMode;
}) => BigDecimal): ((...args: Array<any>) => any) & ((self: BigDecimal, options?: {
scale?: number;
mode?: RoundingMode;
}) => BigDecimal) (+1 overload)
Creates a function that can be called in data-first style or data-last
(pipe-friendly) style.
When to use
Use to expose one implementation through both direct and pipe-friendly
call styles.
Details
Pass either the arity of the uncurried function or a predicate that decides
whether the current call is data-first. Arity is the common case. Use a
predicate when optional arguments make arity ambiguous.
Example (Selecting data-first or data-last style by arity)
import { Function, pipe } from "effect"
const sum = Function.dual<
(that: number) => (self: number) => number,
(self: number, that: number) => number
>(2, (self, that) => self + that)
console.log(sum(2, 3)) // 5
console.log(pipe(2, sum(3))) // 5
Example (Defining overloads with call signatures)
import { Function, pipe } from "effect"
const sum: {
(that: number): (self: number) => number
(self: number, that: number): number
} = Function.dual(2, (self: number, that: number): number => self + that)
console.log(sum(2, 3)) // 5
console.log(pipe(2, sum(3))) // 5
Example (Selecting data-first or data-last style with a predicate)
import { Function, pipe } from "effect"
const sum = Function.dual<
(that: number) => (self: number) => number,
(self: number, that: number) => number
>(
(args) => args.length === 2,
(self, that) => self + that
)
console.log(sum(2, 3)) // 5
console.log(pipe(2, sum(3))) // 5
dual(const isBigDecimalArgs: (
args: IArguments
) => boolean
isBigDecimalArgs, (self: BigDecimal(parameter) self: {
value: bigint;
scale: number;
normalized: BigDecimal;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
self: BigDecimal, options: { scale?: number; mode?: RoundingMode }options?: { scale?: number | undefinedscale?: number; mode?: RoundingModemode?: type RoundingMode =
| "ceil"
| "floor"
| "to-zero"
| "from-zero"
| "half-ceil"
| "half-floor"
| "half-to-zero"
| "half-from-zero"
| "half-even"
| "half-odd"
Rounding modes for BigDecimal.
When to use
Use with round to choose how discarded digits affect a BigDecimal
rounded to a target scale.
Details
ceil: round towards positive infinity
floor: round towards negative infinity
to-zero: round towards zero
from-zero: round away from zero
half-ceil: round to the nearest neighbor; if equidistant round towards positive infinity
half-floor: round to the nearest neighbor; if equidistant round towards negative infinity
half-to-zero: round to the nearest neighbor; if equidistant round towards zero
half-from-zero: round to the nearest neighbor; if equidistant round away from zero
half-even: round to the nearest neighbor; if equidistant round to the neighbor with an even digit
half-odd: round to the nearest neighbor; if equidistant round to the neighbor with an odd digit
RoundingMode }): BigDecimal => {
const const mode: RoundingModemode = options: { scale?: number; mode?: RoundingMode }options?.mode?: RoundingModemode ?? "half-from-zero"
const const scale: numberscale = options: { scale?: number; mode?: RoundingMode }options?.scale?: number | undefinedscale ?? 0
switch (const mode: RoundingModemode) {
case "ceil":
return const ceil: {
(scale: number): (
self: BigDecimal
) => BigDecimal
(self: BigDecimal, scale?: number): BigDecimal
}
ceil(self: BigDecimal(parameter) self: {
value: bigint;
scale: number;
normalized: BigDecimal;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
self, const scale: numberscale)
case "floor":
return const floor: {
(scale: number): (
self: BigDecimal
) => BigDecimal
(self: BigDecimal, scale?: number): BigDecimal
}
floor(self: BigDecimal(parameter) self: {
value: bigint;
scale: number;
normalized: BigDecimal;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
self, const scale: numberscale)
case "to-zero":
return const truncate: {
(scale: number): (
self: BigDecimal
) => BigDecimal
(self: BigDecimal, scale?: number): BigDecimal
}
truncate(self: BigDecimal(parameter) self: {
value: bigint;
scale: number;
normalized: BigDecimal;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
self, const scale: numberscale)
case "from-zero":
return (const isPositive: (
n: BigDecimal
) => boolean
Checks whether a given BigDecimal is positive.
When to use
Use to test whether a BigDecimal is greater than zero.
Example (Checking positive decimals)
import { BigDecimal } from "effect"
import * as assert from "node:assert"
assert.deepStrictEqual(BigDecimal.isPositive(BigDecimal.fromStringUnsafe("-1")), false)
assert.deepStrictEqual(BigDecimal.isPositive(BigDecimal.fromStringUnsafe("0")), false)
assert.deepStrictEqual(BigDecimal.isPositive(BigDecimal.fromStringUnsafe("1")), true)
isPositive(self: BigDecimal(parameter) self: {
value: bigint;
scale: number;
normalized: BigDecimal;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
self) ? const ceil: {
(scale: number): (
self: BigDecimal
) => BigDecimal
(self: BigDecimal, scale?: number): BigDecimal
}
ceil(self: BigDecimal(parameter) self: {
value: bigint;
scale: number;
normalized: BigDecimal;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
self, const scale: numberscale) : const floor: {
(scale: number): (
self: BigDecimal
) => BigDecimal
(self: BigDecimal, scale?: number): BigDecimal
}
floor(self: BigDecimal(parameter) self: {
value: bigint;
scale: number;
normalized: BigDecimal;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
self, const scale: numberscale))
case "half-ceil":
return const floor: {
(scale: number): (
self: BigDecimal
) => BigDecimal
(self: BigDecimal, scale?: number): BigDecimal
}
floor(const sum: {
(that: BigDecimal): (
self: BigDecimal
) => BigDecimal
(self: BigDecimal, that: BigDecimal): BigDecimal
}
sum(self: BigDecimal(parameter) self: {
value: bigint;
scale: number;
normalized: BigDecimal;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
self, const make: (
value: bigint,
scale: number
) => BigDecimal
Creates a BigDecimal from a bigint value and a scale.
When to use
Use to construct a decimal directly from its unscaled integer value and
decimal scale.
Example (Creating decimals from bigint and scale)
import { BigDecimal } from "effect"
// Create 123.45 (12345 with scale 2)
const decimal = BigDecimal.make(12345n, 2)
console.log(BigDecimal.format(decimal)) // "123.45"
// Create 42 (42 with scale 0)
const integer = BigDecimal.make(42n, 0)
console.log(BigDecimal.format(integer)) // "42"
make(const bigint5: bigintbigint5, const scale: numberscale + 1)), const scale: numberscale)
case "half-floor":
return const ceil: {
(scale: number): (
self: BigDecimal
) => BigDecimal
(self: BigDecimal, scale?: number): BigDecimal
}
ceil(const sum: {
(that: BigDecimal): (
self: BigDecimal
) => BigDecimal
(self: BigDecimal, that: BigDecimal): BigDecimal
}
sum(self: BigDecimal(parameter) self: {
value: bigint;
scale: number;
normalized: BigDecimal;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
self, const make: (
value: bigint,
scale: number
) => BigDecimal
Creates a BigDecimal from a bigint value and a scale.
When to use
Use to construct a decimal directly from its unscaled integer value and
decimal scale.
Example (Creating decimals from bigint and scale)
import { BigDecimal } from "effect"
// Create 123.45 (12345 with scale 2)
const decimal = BigDecimal.make(12345n, 2)
console.log(BigDecimal.format(decimal)) // "123.45"
// Create 42 (42 with scale 0)
const integer = BigDecimal.make(42n, 0)
console.log(BigDecimal.format(integer)) // "42"
make(const bigint_5: bigintbigint_5, const scale: numberscale + 1)), const scale: numberscale)
case "half-to-zero":
return const isNegative: (
n: BigDecimal
) => boolean
Checks whether a given BigDecimal is negative.
When to use
Use to test whether a BigDecimal is less than zero.
Example (Checking negative decimals)
import { BigDecimal } from "effect"
import * as assert from "node:assert"
assert.deepStrictEqual(BigDecimal.isNegative(BigDecimal.fromStringUnsafe("-1")), true)
assert.deepStrictEqual(BigDecimal.isNegative(BigDecimal.fromStringUnsafe("0")), false)
assert.deepStrictEqual(BigDecimal.isNegative(BigDecimal.fromStringUnsafe("1")), false)
isNegative(self: BigDecimal(parameter) self: {
value: bigint;
scale: number;
normalized: BigDecimal;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
self)
? const floor: {
(scale: number): (
self: BigDecimal
) => BigDecimal
(self: BigDecimal, scale?: number): BigDecimal
}
floor(const sum: {
(that: BigDecimal): (
self: BigDecimal
) => BigDecimal
(self: BigDecimal, that: BigDecimal): BigDecimal
}
sum(self: BigDecimal(parameter) self: {
value: bigint;
scale: number;
normalized: BigDecimal;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
self, const make: (
value: bigint,
scale: number
) => BigDecimal
Creates a BigDecimal from a bigint value and a scale.
When to use
Use to construct a decimal directly from its unscaled integer value and
decimal scale.
Example (Creating decimals from bigint and scale)
import { BigDecimal } from "effect"
// Create 123.45 (12345 with scale 2)
const decimal = BigDecimal.make(12345n, 2)
console.log(BigDecimal.format(decimal)) // "123.45"
// Create 42 (42 with scale 0)
const integer = BigDecimal.make(42n, 0)
console.log(BigDecimal.format(integer)) // "42"
make(const bigint5: bigintbigint5, const scale: numberscale + 1)), const scale: numberscale)
: const ceil: {
(scale: number): (
self: BigDecimal
) => BigDecimal
(self: BigDecimal, scale?: number): BigDecimal
}
ceil(const sum: {
(that: BigDecimal): (
self: BigDecimal
) => BigDecimal
(self: BigDecimal, that: BigDecimal): BigDecimal
}
sum(self: BigDecimal(parameter) self: {
value: bigint;
scale: number;
normalized: BigDecimal;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
self, const make: (
value: bigint,
scale: number
) => BigDecimal
Creates a BigDecimal from a bigint value and a scale.
When to use
Use to construct a decimal directly from its unscaled integer value and
decimal scale.
Example (Creating decimals from bigint and scale)
import { BigDecimal } from "effect"
// Create 123.45 (12345 with scale 2)
const decimal = BigDecimal.make(12345n, 2)
console.log(BigDecimal.format(decimal)) // "123.45"
// Create 42 (42 with scale 0)
const integer = BigDecimal.make(42n, 0)
console.log(BigDecimal.format(integer)) // "42"
make(const bigint_5: bigintbigint_5, const scale: numberscale + 1)), const scale: numberscale)
case "half-from-zero":
return const isNegative: (
n: BigDecimal
) => boolean
Checks whether a given BigDecimal is negative.
When to use
Use to test whether a BigDecimal is less than zero.
Example (Checking negative decimals)
import { BigDecimal } from "effect"
import * as assert from "node:assert"
assert.deepStrictEqual(BigDecimal.isNegative(BigDecimal.fromStringUnsafe("-1")), true)
assert.deepStrictEqual(BigDecimal.isNegative(BigDecimal.fromStringUnsafe("0")), false)
assert.deepStrictEqual(BigDecimal.isNegative(BigDecimal.fromStringUnsafe("1")), false)
isNegative(self: BigDecimal(parameter) self: {
value: bigint;
scale: number;
normalized: BigDecimal;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
self)
? const ceil: {
(scale: number): (
self: BigDecimal
) => BigDecimal
(self: BigDecimal, scale?: number): BigDecimal
}
ceil(const sum: {
(that: BigDecimal): (
self: BigDecimal
) => BigDecimal
(self: BigDecimal, that: BigDecimal): BigDecimal
}
sum(self: BigDecimal(parameter) self: {
value: bigint;
scale: number;
normalized: BigDecimal;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
self, const make: (
value: bigint,
scale: number
) => BigDecimal
Creates a BigDecimal from a bigint value and a scale.
When to use
Use to construct a decimal directly from its unscaled integer value and
decimal scale.
Example (Creating decimals from bigint and scale)
import { BigDecimal } from "effect"
// Create 123.45 (12345 with scale 2)
const decimal = BigDecimal.make(12345n, 2)
console.log(BigDecimal.format(decimal)) // "123.45"
// Create 42 (42 with scale 0)
const integer = BigDecimal.make(42n, 0)
console.log(BigDecimal.format(integer)) // "42"
make(const bigint_5: bigintbigint_5, const scale: numberscale + 1)), const scale: numberscale)
: const floor: {
(scale: number): (
self: BigDecimal
) => BigDecimal
(self: BigDecimal, scale?: number): BigDecimal
}
floor(const sum: {
(that: BigDecimal): (
self: BigDecimal
) => BigDecimal
(self: BigDecimal, that: BigDecimal): BigDecimal
}
sum(self: BigDecimal(parameter) self: {
value: bigint;
scale: number;
normalized: BigDecimal;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
self, const make: (
value: bigint,
scale: number
) => BigDecimal
Creates a BigDecimal from a bigint value and a scale.
When to use
Use to construct a decimal directly from its unscaled integer value and
decimal scale.
Example (Creating decimals from bigint and scale)
import { BigDecimal } from "effect"
// Create 123.45 (12345 with scale 2)
const decimal = BigDecimal.make(12345n, 2)
console.log(BigDecimal.format(decimal)) // "123.45"
// Create 42 (42 with scale 0)
const integer = BigDecimal.make(42n, 0)
console.log(BigDecimal.format(integer)) // "42"
make(const bigint5: bigintbigint5, const scale: numberscale + 1)), const scale: numberscale)
}
const const halfCeil: BigDecimalconst halfCeil: {
value: bigint;
scale: number;
normalized: BigDecimal;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
halfCeil = const floor: {
(scale: number): (
self: BigDecimal
) => BigDecimal
(self: BigDecimal, scale?: number): BigDecimal
}
floor(const sum: {
(that: BigDecimal): (
self: BigDecimal
) => BigDecimal
(self: BigDecimal, that: BigDecimal): BigDecimal
}
sum(self: BigDecimal(parameter) self: {
value: bigint;
scale: number;
normalized: BigDecimal;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
self, const make: (
value: bigint,
scale: number
) => BigDecimal
Creates a BigDecimal from a bigint value and a scale.
When to use
Use to construct a decimal directly from its unscaled integer value and
decimal scale.
Example (Creating decimals from bigint and scale)
import { BigDecimal } from "effect"
// Create 123.45 (12345 with scale 2)
const decimal = BigDecimal.make(12345n, 2)
console.log(BigDecimal.format(decimal)) // "123.45"
// Create 42 (42 with scale 0)
const integer = BigDecimal.make(42n, 0)
console.log(BigDecimal.format(integer)) // "42"
make(const bigint5: bigintbigint5, const scale: numberscale + 1)), const scale: numberscale)
const const halfFloor: BigDecimalconst halfFloor: {
value: bigint;
scale: number;
normalized: BigDecimal;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
halfFloor = const ceil: {
(scale: number): (
self: BigDecimal
) => BigDecimal
(self: BigDecimal, scale?: number): BigDecimal
}
ceil(const sum: {
(that: BigDecimal): (
self: BigDecimal
) => BigDecimal
(self: BigDecimal, that: BigDecimal): BigDecimal
}
sum(self: BigDecimal(parameter) self: {
value: bigint;
scale: number;
normalized: BigDecimal;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
self, const make: (
value: bigint,
scale: number
) => BigDecimal
Creates a BigDecimal from a bigint value and a scale.
When to use
Use to construct a decimal directly from its unscaled integer value and
decimal scale.
Example (Creating decimals from bigint and scale)
import { BigDecimal } from "effect"
// Create 123.45 (12345 with scale 2)
const decimal = BigDecimal.make(12345n, 2)
console.log(BigDecimal.format(decimal)) // "123.45"
// Create 42 (42 with scale 0)
const integer = BigDecimal.make(42n, 0)
console.log(BigDecimal.format(integer)) // "42"
make(const bigint_5: bigintbigint_5, const scale: numberscale + 1)), const scale: numberscale)
const const digit: bigintdigit = const digitAt: {
(scale: number): (self: BigDecimal) => bigint
(self: BigDecimal, scale: number): bigint
}
digitAt(const halfCeil: BigDecimalconst halfCeil: {
value: bigint;
scale: number;
normalized: BigDecimal;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
halfCeil, const scale: numberscale)
switch (const mode: "half-even" | "half-odd"mode) {
case "half-even":
return const equals: {
(that: BigDecimal): (
self: BigDecimal
) => boolean
(self: BigDecimal, that: BigDecimal): boolean
}
equals(const halfCeil: BigDecimalconst halfCeil: {
value: bigint;
scale: number;
normalized: BigDecimal;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
halfCeil, const halfFloor: BigDecimalconst halfFloor: {
value: bigint;
scale: number;
normalized: BigDecimal;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
halfFloor) ? const halfCeil: BigDecimalconst halfCeil: {
value: bigint;
scale: number;
normalized: BigDecimal;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
halfCeil : (const digit: bigintdigit % const bigint2: bigintbigint2 === const bigint0: bigintbigint0) ? const halfCeil: BigDecimalconst halfCeil: {
value: bigint;
scale: number;
normalized: BigDecimal;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
halfCeil : const halfFloor: BigDecimalconst halfFloor: {
value: bigint;
scale: number;
normalized: BigDecimal;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
halfFloor
case "half-odd":
return const equals: {
(that: BigDecimal): (
self: BigDecimal
) => boolean
(self: BigDecimal, that: BigDecimal): boolean
}
equals(const halfCeil: BigDecimalconst halfCeil: {
value: bigint;
scale: number;
normalized: BigDecimal;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
halfCeil, const halfFloor: BigDecimalconst halfFloor: {
value: bigint;
scale: number;
normalized: BigDecimal;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
halfFloor) ? const halfCeil: BigDecimalconst halfCeil: {
value: bigint;
scale: number;
normalized: BigDecimal;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
halfCeil : (const digit: bigintdigit % const bigint2: bigintbigint2 === const bigint0: bigintbigint0) ? const halfFloor: BigDecimalconst halfFloor: {
value: bigint;
scale: number;
normalized: BigDecimal;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
halfFloor : const halfCeil: BigDecimalconst halfCeil: {
value: bigint;
scale: number;
normalized: BigDecimal;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
halfCeil
}
})