Long

Js Long

此脚本不应直接安装。它是供其他脚本使用的外部库,要使用该库请加入元指令 // @require https://update.gf.qytechs.cn/scripts/449789/1083020/Long.js

  1. class t {
  2. Long = null;
  3. }
  4.  
  5. t.Long = function(t, e) {
  6. this.low_ = 0 | t,
  7. this.high_ = 0 | e
  8. }
  9. ,
  10. t.Long.$metadata$ = {
  11. kind: "class",
  12. simpleName: "Long",
  13. interfaces: []
  14. },
  15. t.Long.IntCache_ = {},
  16. t.Long.fromInt = function(e) {
  17. if (-128 <= e && e < 128) {
  18. var n = t.Long.IntCache_[e];
  19. if (n)
  20. return n
  21. }
  22. var o = new t.Long(0 | e,e < 0 ? -1 : 0);
  23. return -128 <= e && e < 128 && (t.Long.IntCache_[e] = o),
  24. o
  25. }
  26. ,
  27. t.Long.fromNumber = function(e) {
  28. return isNaN(e) ? t.Long.ZERO : e <= -t.Long.TWO_PWR_63_DBL_ ? t.Long.MIN_VALUE : e + 1 >= t.Long.TWO_PWR_63_DBL_ ? t.Long.MAX_VALUE : e < 0 ? t.Long.fromNumber(-e).negate() : new t.Long(e % t.Long.TWO_PWR_32_DBL_ | 0,e / t.Long.TWO_PWR_32_DBL_ | 0)
  29. }
  30. ,
  31. t.Long.fromBits = function(e, n) {
  32. return new t.Long(e,n)
  33. }
  34. ,
  35. t.Long.fromString = function(e, n) {
  36. if (0 == e.length)
  37. throw Error("number format error: empty string");
  38. var o = n || 10;
  39. if (o < 2 || 36 < o)
  40. throw Error("radix out of range: " + o);
  41. if ("-" == e.charAt(0))
  42. return t.Long.fromString(e.substring(1), o).negate();
  43. if (e.indexOf("-") >= 0)
  44. throw Error('number format error: interior "-" character: ' + e);
  45. for (var i = t.Long.fromNumber(Math.pow(o, 8)), r = t.Long.ZERO, s = 0; s < e.length; s += 8) {
  46. var a = Math.min(8, e.length - s)
  47. , c = parseInt(e.substring(s, s + a), o);
  48. if (a < 8) {
  49. var u = t.Long.fromNumber(Math.pow(o, a));
  50. r = r.multiply(u).add(t.Long.fromNumber(c))
  51. } else
  52. r = (r = r.multiply(i)).add(t.Long.fromNumber(c))
  53. }
  54. return r
  55. }
  56. ,
  57. t.Long.TWO_PWR_16_DBL_ = 65536,
  58. t.Long.TWO_PWR_24_DBL_ = 1 << 24,
  59. t.Long.TWO_PWR_32_DBL_ = t.Long.TWO_PWR_16_DBL_ * t.Long.TWO_PWR_16_DBL_,
  60. t.Long.TWO_PWR_31_DBL_ = t.Long.TWO_PWR_32_DBL_ / 2,
  61. t.Long.TWO_PWR_48_DBL_ = t.Long.TWO_PWR_32_DBL_ * t.Long.TWO_PWR_16_DBL_,
  62. t.Long.TWO_PWR_64_DBL_ = t.Long.TWO_PWR_32_DBL_ * t.Long.TWO_PWR_32_DBL_,
  63. t.Long.TWO_PWR_63_DBL_ = t.Long.TWO_PWR_64_DBL_ / 2,
  64. t.Long.ZERO = t.Long.fromInt(0),
  65. t.Long.ONE = t.Long.fromInt(1),
  66. t.Long.NEG_ONE = t.Long.fromInt(-1),
  67. t.Long.MAX_VALUE = t.Long.fromBits(-1, 2147483647),
  68. t.Long.MIN_VALUE = t.Long.fromBits(0, -2147483648),
  69. t.Long.TWO_PWR_24_ = t.Long.fromInt(1 << 24),
  70. t.Long.prototype.toInt = function() {
  71. return this.low_
  72. }
  73. ,
  74. t.Long.prototype.toNumber = function() {
  75. return this.high_ * t.Long.TWO_PWR_32_DBL_ + this.getLowBitsUnsigned()
  76. }
  77. ,
  78. t.Long.prototype.hashCode = function() {
  79. return this.high_ ^ this.low_
  80. }
  81. ,
  82. t.Long.prototype.toString = function(e) {
  83. var n = e || 10;
  84. if (n < 2 || 36 < n)
  85. throw Error("radix out of range: " + n);
  86. if (this.isZero())
  87. return "0";
  88. if (this.isNegative()) {
  89. if (this.equalsLong(t.Long.MIN_VALUE)) {
  90. var o = t.Long.fromNumber(n)
  91. , i = this.div(o)
  92. , r = i.multiply(o).subtract(this);
  93. return i.toString(n) + r.toInt().toString(n)
  94. }
  95. return "-" + this.negate().toString(n)
  96. }
  97. for (var s = t.Long.fromNumber(Math.pow(n, 6)), a = (r = this,
  98. ""); ; ) {
  99. var c = r.div(s)
  100. , u = r.subtract(c.multiply(s)).toInt().toString(n);
  101. if ((r = c).isZero())
  102. return u + a;
  103. for (; u.length < 6; )
  104. u = "0" + u;
  105. a = "" + u + a
  106. }
  107. }
  108. ,
  109. t.Long.prototype.getHighBits = function() {
  110. return this.high_
  111. }
  112. ,
  113. t.Long.prototype.getLowBits = function() {
  114. return this.low_
  115. }
  116. ,
  117. t.Long.prototype.getLowBitsUnsigned = function() {
  118. return this.low_ >= 0 ? this.low_ : t.Long.TWO_PWR_32_DBL_ + this.low_
  119. }
  120. ,
  121. t.Long.prototype.getNumBitsAbs = function() {
  122. if (this.isNegative())
  123. return this.equalsLong(t.Long.MIN_VALUE) ? 64 : this.negate().getNumBitsAbs();
  124. for (var e = 0 != this.high_ ? this.high_ : this.low_, n = 31; n > 0 && 0 == (e & 1 << n); n--)
  125. ;
  126. return 0 != this.high_ ? n + 33 : n + 1
  127. }
  128. ,
  129. t.Long.prototype.isZero = function() {
  130. return 0 == this.high_ && 0 == this.low_
  131. }
  132. ,
  133. t.Long.prototype.isNegative = function() {
  134. return this.high_ < 0
  135. }
  136. ,
  137. t.Long.prototype.isOdd = function() {
  138. return 1 == (1 & this.low_)
  139. }
  140. ,
  141. t.Long.prototype.equalsLong = function(t) {
  142. return this.high_ == t.high_ && this.low_ == t.low_
  143. }
  144. ,
  145. t.Long.prototype.notEqualsLong = function(t) {
  146. return this.high_ != t.high_ || this.low_ != t.low_
  147. }
  148. ,
  149. t.Long.prototype.lessThan = function(t) {
  150. return this.compare(t) < 0
  151. }
  152. ,
  153. t.Long.prototype.lessThanOrEqual = function(t) {
  154. return this.compare(t) <= 0
  155. }
  156. ,
  157. t.Long.prototype.greaterThan = function(t) {
  158. return this.compare(t) > 0
  159. }
  160. ,
  161. t.Long.prototype.greaterThanOrEqual = function(t) {
  162. return this.compare(t) >= 0
  163. }
  164. ,
  165. t.Long.prototype.compare = function(t) {
  166. if (this.equalsLong(t))
  167. return 0;
  168. var e = this.isNegative()
  169. , n = t.isNegative();
  170. return e && !n ? -1 : !e && n ? 1 : this.subtract(t).isNegative() ? -1 : 1
  171. }
  172. ,
  173. t.Long.prototype.negate = function() {
  174. return this.equalsLong(t.Long.MIN_VALUE) ? t.Long.MIN_VALUE : this.not().add(t.Long.ONE)
  175. }
  176. ,
  177. t.Long.prototype.add = function(e) {
  178. var n = this.high_ >>> 16
  179. , o = 65535 & this.high_
  180. , i = this.low_ >>> 16
  181. , r = 65535 & this.low_
  182. , s = e.high_ >>> 16
  183. , a = 65535 & e.high_
  184. , c = e.low_ >>> 16
  185. , u = 0
  186. , l = 0
  187. , _ = 0
  188. , p = 0;
  189. return _ += (p += r + (65535 & e.low_)) >>> 16,
  190. p &= 65535,
  191. l += (_ += i + c) >>> 16,
  192. _ &= 65535,
  193. u += (l += o + a) >>> 16,
  194. l &= 65535,
  195. u += n + s,
  196. u &= 65535,
  197. t.Long.fromBits(_ << 16 | p, u << 16 | l)
  198. }
  199. ,
  200. t.Long.prototype.subtract = function(t) {
  201. return this.add(t.negate())
  202. }
  203. ,
  204. t.Long.prototype.multiply = function(e) {
  205. if (this.isZero())
  206. return t.Long.ZERO;
  207. if (e.isZero())
  208. return t.Long.ZERO;
  209. if (this.equalsLong(t.Long.MIN_VALUE))
  210. return e.isOdd() ? t.Long.MIN_VALUE : t.Long.ZERO;
  211. if (e.equalsLong(t.Long.MIN_VALUE))
  212. return this.isOdd() ? t.Long.MIN_VALUE : t.Long.ZERO;
  213. if (this.isNegative())
  214. return e.isNegative() ? this.negate().multiply(e.negate()) : this.negate().multiply(e).negate();
  215. if (e.isNegative())
  216. return this.multiply(e.negate()).negate();
  217. if (this.lessThan(t.Long.TWO_PWR_24_) && e.lessThan(t.Long.TWO_PWR_24_))
  218. return t.Long.fromNumber(this.toNumber() * e.toNumber());
  219. var n = this.high_ >>> 16
  220. , o = 65535 & this.high_
  221. , i = this.low_ >>> 16
  222. , r = 65535 & this.low_
  223. , s = e.high_ >>> 16
  224. , a = 65535 & e.high_
  225. , c = e.low_ >>> 16
  226. , u = 65535 & e.low_
  227. , l = 0
  228. , _ = 0
  229. , p = 0
  230. , h = 0;
  231. return p += (h += r * u) >>> 16,
  232. h &= 65535,
  233. _ += (p += i * u) >>> 16,
  234. p &= 65535,
  235. _ += (p += r * c) >>> 16,
  236. p &= 65535,
  237. l += (_ += o * u) >>> 16,
  238. _ &= 65535,
  239. l += (_ += i * c) >>> 16,
  240. _ &= 65535,
  241. l += (_ += r * a) >>> 16,
  242. _ &= 65535,
  243. l += n * u + o * c + i * a + r * s,
  244. l &= 65535,
  245. t.Long.fromBits(p << 16 | h, l << 16 | _)
  246. }
  247. ,
  248. t.Long.prototype.div = function(e) {
  249. if (e.isZero())
  250. throw Error("division by zero");
  251. if (this.isZero())
  252. return t.Long.ZERO;
  253. if (this.equalsLong(t.Long.MIN_VALUE)) {
  254. if (e.equalsLong(t.Long.ONE) || e.equalsLong(t.Long.NEG_ONE))
  255. return t.Long.MIN_VALUE;
  256. if (e.equalsLong(t.Long.MIN_VALUE))
  257. return t.Long.ONE;
  258. if ((i = this.shiftRight(1).div(e).shiftLeft(1)).equalsLong(t.Long.ZERO))
  259. return e.isNegative() ? t.Long.ONE : t.Long.NEG_ONE;
  260. var n = this.subtract(e.multiply(i));
  261. return i.add(n.div(e))
  262. }
  263. if (e.equalsLong(t.Long.MIN_VALUE))
  264. return t.Long.ZERO;
  265. if (this.isNegative())
  266. return e.isNegative() ? this.negate().div(e.negate()) : this.negate().div(e).negate();
  267. if (e.isNegative())
  268. return this.div(e.negate()).negate();
  269. var o = t.Long.ZERO;
  270. for (n = this; n.greaterThanOrEqual(e); ) {
  271. for (var i = Math.max(1, Math.floor(n.toNumber() / e.toNumber())), r = Math.ceil(Math.log(i) / Math.LN2), s = r <= 48 ? 1 : Math.pow(2, r - 48), a = t.Long.fromNumber(i), c = a.multiply(e); c.isNegative() || c.greaterThan(n); )
  272. i -= s,
  273. c = (a = t.Long.fromNumber(i)).multiply(e);
  274. a.isZero() && (a = t.Long.ONE),
  275. o = o.add(a),
  276. n = n.subtract(c)
  277. }
  278. return o
  279. }
  280. ,
  281. t.Long.prototype.modulo = function(t) {
  282. return this.subtract(this.div(t).multiply(t))
  283. }
  284. ,
  285. t.Long.prototype.not = function() {
  286. return t.Long.fromBits(~this.low_, ~this.high_)
  287. }
  288. ,
  289. t.Long.prototype.and = function(e) {
  290. return t.Long.fromBits(this.low_ & e.low_, this.high_ & e.high_)
  291. }
  292. ,
  293. t.Long.prototype.or = function(e) {
  294. return t.Long.fromBits(this.low_ | e.low_, this.high_ | e.high_)
  295. }
  296. ,
  297. t.Long.prototype.xor = function(e) {
  298. return t.Long.fromBits(this.low_ ^ e.low_, this.high_ ^ e.high_)
  299. }
  300. ,
  301. t.Long.prototype.shiftLeft = function(e) {
  302. if (0 == (e &= 63))
  303. return this;
  304. var n = this.low_;
  305. if (e < 32) {
  306. var o = this.high_;
  307. return t.Long.fromBits(n << e, o << e | n >>> 32 - e)
  308. }
  309. return t.Long.fromBits(0, n << e - 32)
  310. }
  311. ,
  312. t.Long.prototype.shiftRight = function(e) {
  313. if (0 == (e &= 63))
  314. return this;
  315. var n = this.high_;
  316. if (e < 32) {
  317. var o = this.low_;
  318. return t.Long.fromBits(o >>> e | n << 32 - e, n >> e)
  319. }
  320. return t.Long.fromBits(n >> e - 32, n >= 0 ? 0 : -1)
  321. }
  322. ,
  323. t.Long.prototype.shiftRightUnsigned = function(e) {
  324. if (0 == (e &= 63))
  325. return this;
  326. var n = this.high_;
  327. if (e < 32) {
  328. var o = this.low_;
  329. return t.Long.fromBits(o >>> e | n << 32 - e, n >>> e)
  330. }
  331. return 32 == e ? t.Long.fromBits(n, 0) : t.Long.fromBits(n >>> e - 32, 0)
  332. }
  333. ,
  334. t.Long.prototype.equals = function(e) {
  335. return e instanceof t.Long && this.equalsLong(e)
  336. }
  337. ,
  338. t.Long.prototype.compareTo_11rb$ = t.Long.prototype.compare,
  339. t.Long.prototype.inc = function() {
  340. return this.add(t.Long.ONE)
  341. }
  342. ,
  343. t.Long.prototype.dec = function() {
  344. return this.add(t.Long.NEG_ONE)
  345. }
  346. ,
  347. t.Long.prototype.valueOf = function() {
  348. return this.toNumber()
  349. }
  350. ,
  351. t.Long.prototype.unaryPlus = function() {
  352. return this
  353. }
  354. ,
  355. t.Long.prototype.unaryMinus = t.Long.prototype.negate,
  356. t.Long.prototype.inv = t.Long.prototype.not,
  357. t.Long.prototype.rangeTo = function(e) {
  358. return new t.kotlin.ranges.LongRange(this,e)
  359. }

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址