BigInt
asIntN
RESCRIPT
let asIntN: (~width: int, bigint) => bigint
asUintN
RESCRIPT
let asUintN: (~width: int, bigint) => bigint
fromString
RESCRIPT
let fromString: string => bigint
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 */
BigInt.fromStringExn("123")
/* returns 0n */
BigInt.fromStringExn("")
/* returns 17n */
BigInt.fromStringExn("0x11")
/* returns 3n */
BigInt.fromStringExn("0b11")
/* returns 9n */
BigInt.fromStringExn("0o11")
/* catch exception */
try {
BigInt.fromStringExn("a")
} catch {
| Exn.Error(_error) => 0n
}
fromInt
RESCRIPT
let fromInt: int => bigint
fromFloat
RESCRIPT
let fromFloat: float => bigint
toString
RESCRIPT
let toString: (bigint, ~radix: int=?) => 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
toStringWithRadix
Deprecated
Use toString
with ~radix
instead
RESCRIPT
let toStringWithRadix: (bigint, ~radix: int) => string
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
toFloat
RESCRIPT
let toFloat: bigint => float
toInt
RESCRIPT
let toInt: bigint => int
+
RESCRIPT
let +: (bigint, bigint) => bigint
-
RESCRIPT
let -: (bigint, bigint) => bigint
*
RESCRIPT
let *: (bigint, bigint) => bigint
/
RESCRIPT
let /: (bigint, bigint) => bigint
~-
RESCRIPT
let ~-: bigint => bigint
~+
RESCRIPT
let ~+: bigint => bigint
**
RESCRIPT
let **: (bigint, bigint) => bigint
add
RESCRIPT
let add: (bigint, bigint) => bigint
sub
RESCRIPT
let sub: (bigint, bigint) => bigint
mul
RESCRIPT
let mul: (bigint, bigint) => bigint
div
RESCRIPT
let div: (bigint, bigint) => bigint
mod
RESCRIPT
let mod: (bigint, bigint) => bigint
land
RESCRIPT
let land: (bigint, bigint) => bigint
lor
RESCRIPT
let lor: (bigint, bigint) => bigint
lxor
RESCRIPT
let lxor: (bigint, bigint) => bigint
lsl
RESCRIPT
let lsl: (bigint, bigint) => bigint
asr
RESCRIPT
let asr: (bigint, bigint) => bigint
lnot
RESCRIPT
let lnot: bigint => bigint