API / Js / Bigint

BigInt

JavaScript BigInt API

fromStringExn

RESCRIPT
let fromStringExn: string => bigint

Parses the given string into a bigint using JavaScript semantics. Return the number as a bigint if successfully parsed. Uncaught syntax exception otherwise.

Examples

RESCRIPT
/* returns 123n */ Js.BigInt.fromStringExn("123") /* returns 0n */ Js.BigInt.fromStringExn("") /* returns 17n */ Js.BigInt.fromStringExn("0x11") /* returns 3n */ Js.BigInt.fromStringExn("0b11") /* returns 9n */ Js.BigInt.fromStringExn("0o11") /* catch exception */ try { Js.BigInt.fromStringExn("a") } catch { | _ => ... }

~-

RESCRIPT
let ~-: bigint => bigint

~+

RESCRIPT
let ~+: bigint => bigint

+

RESCRIPT
let +: (bigint, bigint) => bigint

-

RESCRIPT
let -: (bigint, bigint) => bigint

*

RESCRIPT
let *: (bigint, bigint) => bigint

/

RESCRIPT
let /: (bigint, bigint) => bigint

mod

RESCRIPT
let mod: (bigint, bigint) => bigint

**

RESCRIPT
let **: (bigint, bigint) => bigint

land

RESCRIPT
let land: (bigint, bigint) => bigint

lor

RESCRIPT
let lor: (bigint, bigint) => bigint

lxor

RESCRIPT
let lxor: (bigint, bigint) => bigint

lnot

RESCRIPT
let lnot: bigint => bigint

lsl

RESCRIPT
let lsl: (bigint, bigint) => bigint

asr

RESCRIPT
let asr: (bigint, bigint) => bigint

toString

RESCRIPT
let toString: bigint => string

Formats a bigint as a string. Return a string representing the given value. See toString on MDN.

Examples

RESCRIPT
/* prints "123" */ Js.BigInt.toString(123n)->Js.log

toLocaleString

RESCRIPT
let toLocaleString: bigint => string

Returns a string with a language-sensitive representation of this BigInt value.

Examples

RESCRIPT
/* prints "123" */ Js.BigInt.toString(123n)->Js.log