API
| Function | Returns |
|---|---|
toBigInt(v) | bigint |
toNumber(v) | number (may lose precision) |
toHex(v) | hex string |
equals(a, b) | boolean |
Constants
MAX, MIN, ZERO, ONE, NEG_ONESigned 128-bit integer (-2¹²⁷ to 2¹²⁷-1)
import * as Int128 from 'voltaire-effect/primitives/Int128'
import * as Schema from 'effect/Schema'
import { Effect } from 'effect'
// Schema
const value = Schema.decodeSync(Int128.BigInt)(170141183460469231731687303715884105727n)
const fromString = Schema.decodeSync(Int128.String)('-1000000000000000000000')
// Arithmetic
const program = Effect.gen(function* () {
const a = yield* Int128.from(1000000000000000000000n)
const b = yield* Int128.from(500000000000000000000n)
return yield* Int128.minus(a, b)
})
| Function | Returns |
|---|---|
toBigInt(v) | bigint |
toNumber(v) | number (may lose precision) |
toHex(v) | hex string |
equals(a, b) | boolean |
MAX, MIN, ZERO, ONE, NEG_ONE