DKL9 GitList
Repositories
DKL9 home
rtensor
Code
Commits
Branches
Tags
Search
Tree:
1312198
Branches
Tags
master
rtensor
types
bigint.js
Import v2.3-dev from a demonic ritual
dkl9
commited
1312198
at 2023-184 18:25:57
bigint.js
Blame
History
Raw
"use strict"; BasicNumber.keys.forEach(k => (BigInt.prototype[k] = BasicNumber.prototype[k])); BigInt.ify = function(x) { if (typeof x == "object" && x.constructor == Complex) { return x.im ? null : BigInt(Math.floor(x.re)); } else if (typeof x == "number") { return BigInt(x); } else { return x; } }; BigInt.prototype.invalid = () => false; BigInt.zero = () => 0n; BigInt.one = () => 1n; BigInt.prototype.add = function(n) { return this + n; }; BigInt.prototype.neg = function() { return -this; }; BigInt.prototype.mul = function(n) { return this * n; }; BigInt.prototype.div = function(n) { return this / n; }; BigInt.prototype.exp = function() { return 2n ** this; }; BigInt.prototype.pow = function(n) { return this ** n; }; BigInt.prototype.eq = function(n) { return this == n; }; BigInt.prototype.lt = function(n) { return this < n; }; BigInt.prototype.mag = function() { return Math.abs((new Number(this)).valueOf()); }; BigInt.prototype.floor = function() { return this; };