Skip to main content
Signed 64-bit integer with overflow checking.
import * as Int64 from 'voltaire-effect/Int64'
import * as Schema from 'effect/Schema'
import { Effect } from 'effect'

// Schema
const value = Schema.decodeSync(Int64.BigInt)(9223372036854775807n)
const fromString = Schema.decodeSync(Int64.String)('-1000000000000')

// Arithmetic
const a = Effect.runSync(Int64.from(1000000000000n))
const b = Effect.runSync(Int64.from(2000000000000n))
const sum = Effect.runSync(Int64.plus(a, b)) // 3000000000000n

API

FunctionReturns
toBigInt(v)bigint
toNumber(v)number (may lose precision)
toHex(v)hex string
equals(a, b)boolean

Constants

INT64_MIN = -9223372036854775808n, INT64_MAX = 9223372036854775807n