@formatjs/intl-relativetimeformat 12.2.3 → 12.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (575) hide show
  1. package/locale-data/af-NA.js +309 -0
  2. package/locale-data/af.js +309 -0
  3. package/locale-data/agq.js +255 -0
  4. package/locale-data/ak.js +303 -0
  5. package/locale-data/am.js +309 -0
  6. package/locale-data/ar-AE.js +501 -0
  7. package/locale-data/ar-BH.js +501 -0
  8. package/locale-data/ar-DJ.js +501 -0
  9. package/locale-data/ar-DZ.js +501 -0
  10. package/locale-data/ar-EG.js +501 -0
  11. package/locale-data/ar-EH.js +501 -0
  12. package/locale-data/ar-ER.js +501 -0
  13. package/locale-data/ar-IL.js +501 -0
  14. package/locale-data/ar-IQ.js +501 -0
  15. package/locale-data/ar-JO.js +501 -0
  16. package/locale-data/ar-KM.js +501 -0
  17. package/locale-data/ar-KW.js +501 -0
  18. package/locale-data/ar-LB.js +501 -0
  19. package/locale-data/ar-LY.js +501 -0
  20. package/locale-data/ar-MA.js +501 -0
  21. package/locale-data/ar-MR.js +501 -0
  22. package/locale-data/ar-OM.js +501 -0
  23. package/locale-data/ar-PS.js +501 -0
  24. package/locale-data/ar-QA.js +501 -0
  25. package/locale-data/ar-SA.js +501 -0
  26. package/locale-data/ar-SD.js +501 -0
  27. package/locale-data/ar-SO.js +501 -0
  28. package/locale-data/ar-SS.js +501 -0
  29. package/locale-data/ar-SY.js +501 -0
  30. package/locale-data/ar-TD.js +501 -0
  31. package/locale-data/ar-TN.js +501 -0
  32. package/locale-data/ar-YE.js +501 -0
  33. package/locale-data/ar.js +501 -0
  34. package/locale-data/as.js +309 -0
  35. package/locale-data/asa.js +255 -0
  36. package/locale-data/ast.js +309 -0
  37. package/locale-data/az-Cyrl.js +255 -0
  38. package/locale-data/az-Latn.js +303 -0
  39. package/locale-data/az.js +303 -0
  40. package/locale-data/bas.js +255 -0
  41. package/locale-data/be-tarask.js +405 -0
  42. package/locale-data/be.js +405 -0
  43. package/locale-data/bem.js +255 -0
  44. package/locale-data/bez.js +255 -0
  45. package/locale-data/bg.js +309 -0
  46. package/locale-data/bm.js +255 -0
  47. package/locale-data/bn-IN.js +309 -0
  48. package/locale-data/bn.js +309 -0
  49. package/locale-data/bo-IN.js +261 -0
  50. package/locale-data/bo.js +261 -0
  51. package/locale-data/br.js +450 -0
  52. package/locale-data/brx.js +303 -0
  53. package/locale-data/bs-Cyrl.js +345 -0
  54. package/locale-data/bs-Latn.js +357 -0
  55. package/locale-data/bs.js +357 -0
  56. package/locale-data/ca-AD.js +309 -0
  57. package/locale-data/ca-ES-valencia.js +309 -0
  58. package/locale-data/ca-FR.js +309 -0
  59. package/locale-data/ca-IT.js +309 -0
  60. package/locale-data/ca.js +309 -0
  61. package/locale-data/ccp-IN.js +268 -0
  62. package/locale-data/ccp.js +268 -0
  63. package/locale-data/ce.js +303 -0
  64. package/locale-data/ceb.js +255 -0
  65. package/locale-data/cgg.js +255 -0
  66. package/locale-data/chr.js +303 -0
  67. package/locale-data/ckb-IR.js +255 -0
  68. package/locale-data/ckb.js +255 -0
  69. package/locale-data/cs.js +405 -0
  70. package/locale-data/cy.js +501 -0
  71. package/locale-data/da-GL.js +309 -0
  72. package/locale-data/da.js +309 -0
  73. package/locale-data/dav.js +255 -0
  74. package/locale-data/de-AT.js +309 -0
  75. package/locale-data/de-BE.js +309 -0
  76. package/locale-data/de-CH.js +309 -0
  77. package/locale-data/de-IT.js +309 -0
  78. package/locale-data/de-LI.js +309 -0
  79. package/locale-data/de-LU.js +309 -0
  80. package/locale-data/de.js +309 -0
  81. package/locale-data/dje.js +255 -0
  82. package/locale-data/doi.js +255 -0
  83. package/locale-data/dsb.js +399 -0
  84. package/locale-data/dua.js +255 -0
  85. package/locale-data/dyo.js +255 -0
  86. package/locale-data/dz.js +261 -0
  87. package/locale-data/ebu.js +255 -0
  88. package/locale-data/ee-TG.js +309 -0
  89. package/locale-data/ee.js +309 -0
  90. package/locale-data/el-CY.js +309 -0
  91. package/locale-data/el.js +309 -0
  92. package/locale-data/en-001.js +303 -0
  93. package/locale-data/en-150.js +303 -0
  94. package/locale-data/en-AE.js +303 -0
  95. package/locale-data/en-AG.js +303 -0
  96. package/locale-data/en-AI.js +303 -0
  97. package/locale-data/en-AS.js +303 -0
  98. package/locale-data/en-AT.js +303 -0
  99. package/locale-data/en-AU.js +303 -0
  100. package/locale-data/en-BB.js +303 -0
  101. package/locale-data/en-BE.js +303 -0
  102. package/locale-data/en-BI.js +303 -0
  103. package/locale-data/en-BM.js +303 -0
  104. package/locale-data/en-BS.js +303 -0
  105. package/locale-data/en-BW.js +303 -0
  106. package/locale-data/en-BZ.js +303 -0
  107. package/locale-data/en-CA.js +303 -0
  108. package/locale-data/en-CC.js +303 -0
  109. package/locale-data/en-CH.js +303 -0
  110. package/locale-data/en-CK.js +303 -0
  111. package/locale-data/en-CM.js +303 -0
  112. package/locale-data/en-CX.js +303 -0
  113. package/locale-data/en-CY.js +303 -0
  114. package/locale-data/en-DE.js +303 -0
  115. package/locale-data/en-DG.js +303 -0
  116. package/locale-data/en-DK.js +303 -0
  117. package/locale-data/en-DM.js +303 -0
  118. package/locale-data/en-ER.js +303 -0
  119. package/locale-data/en-FI.js +303 -0
  120. package/locale-data/en-FJ.js +303 -0
  121. package/locale-data/en-FK.js +303 -0
  122. package/locale-data/en-FM.js +303 -0
  123. package/locale-data/en-GB.js +303 -0
  124. package/locale-data/en-GD.js +303 -0
  125. package/locale-data/en-GG.js +303 -0
  126. package/locale-data/en-GH.js +303 -0
  127. package/locale-data/en-GI.js +303 -0
  128. package/locale-data/en-GM.js +303 -0
  129. package/locale-data/en-GU.js +303 -0
  130. package/locale-data/en-GY.js +303 -0
  131. package/locale-data/en-HK.js +303 -0
  132. package/locale-data/en-IE.js +303 -0
  133. package/locale-data/en-IL.js +303 -0
  134. package/locale-data/en-IM.js +303 -0
  135. package/locale-data/en-IN.js +303 -0
  136. package/locale-data/en-IO.js +303 -0
  137. package/locale-data/en-JE.js +303 -0
  138. package/locale-data/en-JM.js +303 -0
  139. package/locale-data/en-KE.js +303 -0
  140. package/locale-data/en-KI.js +303 -0
  141. package/locale-data/en-KN.js +303 -0
  142. package/locale-data/en-KY.js +303 -0
  143. package/locale-data/en-LC.js +303 -0
  144. package/locale-data/en-LR.js +303 -0
  145. package/locale-data/en-LS.js +303 -0
  146. package/locale-data/en-MG.js +303 -0
  147. package/locale-data/en-MH.js +303 -0
  148. package/locale-data/en-MO.js +303 -0
  149. package/locale-data/en-MP.js +303 -0
  150. package/locale-data/en-MS.js +303 -0
  151. package/locale-data/en-MT.js +303 -0
  152. package/locale-data/en-MU.js +303 -0
  153. package/locale-data/en-MW.js +303 -0
  154. package/locale-data/en-MY.js +303 -0
  155. package/locale-data/en-NA.js +303 -0
  156. package/locale-data/en-NF.js +303 -0
  157. package/locale-data/en-NG.js +303 -0
  158. package/locale-data/en-NL.js +303 -0
  159. package/locale-data/en-NR.js +303 -0
  160. package/locale-data/en-NU.js +303 -0
  161. package/locale-data/en-NZ.js +303 -0
  162. package/locale-data/en-PG.js +303 -0
  163. package/locale-data/en-PH.js +303 -0
  164. package/locale-data/en-PK.js +303 -0
  165. package/locale-data/en-PN.js +303 -0
  166. package/locale-data/en-PR.js +303 -0
  167. package/locale-data/en-PW.js +303 -0
  168. package/locale-data/en-RW.js +303 -0
  169. package/locale-data/en-SB.js +303 -0
  170. package/locale-data/en-SC.js +303 -0
  171. package/locale-data/en-SD.js +303 -0
  172. package/locale-data/en-SE.js +303 -0
  173. package/locale-data/en-SG.js +303 -0
  174. package/locale-data/en-SH.js +303 -0
  175. package/locale-data/en-SI.js +303 -0
  176. package/locale-data/en-SL.js +303 -0
  177. package/locale-data/en-SS.js +303 -0
  178. package/locale-data/en-SX.js +303 -0
  179. package/locale-data/en-SZ.js +303 -0
  180. package/locale-data/en-TC.js +303 -0
  181. package/locale-data/en-TK.js +303 -0
  182. package/locale-data/en-TO.js +303 -0
  183. package/locale-data/en-TT.js +303 -0
  184. package/locale-data/en-TV.js +303 -0
  185. package/locale-data/en-TZ.js +303 -0
  186. package/locale-data/en-UG.js +303 -0
  187. package/locale-data/en-UM.js +303 -0
  188. package/locale-data/en-VC.js +303 -0
  189. package/locale-data/en-VG.js +303 -0
  190. package/locale-data/en-VI.js +303 -0
  191. package/locale-data/en-VU.js +303 -0
  192. package/locale-data/en-WS.js +303 -0
  193. package/locale-data/en-ZA.js +303 -0
  194. package/locale-data/en-ZM.js +303 -0
  195. package/locale-data/en-ZW.js +303 -0
  196. package/locale-data/en.js +303 -0
  197. package/locale-data/eo.js +303 -0
  198. package/locale-data/es-419.js +309 -0
  199. package/locale-data/es-AR.js +309 -0
  200. package/locale-data/es-BO.js +309 -0
  201. package/locale-data/es-BR.js +309 -0
  202. package/locale-data/es-BZ.js +309 -0
  203. package/locale-data/es-CL.js +309 -0
  204. package/locale-data/es-CO.js +309 -0
  205. package/locale-data/es-CR.js +309 -0
  206. package/locale-data/es-CU.js +309 -0
  207. package/locale-data/es-DO.js +309 -0
  208. package/locale-data/es-EA.js +309 -0
  209. package/locale-data/es-EC.js +309 -0
  210. package/locale-data/es-GQ.js +309 -0
  211. package/locale-data/es-GT.js +309 -0
  212. package/locale-data/es-HN.js +309 -0
  213. package/locale-data/es-IC.js +309 -0
  214. package/locale-data/es-MX.js +309 -0
  215. package/locale-data/es-NI.js +309 -0
  216. package/locale-data/es-PA.js +309 -0
  217. package/locale-data/es-PE.js +309 -0
  218. package/locale-data/es-PH.js +309 -0
  219. package/locale-data/es-PR.js +309 -0
  220. package/locale-data/es-PY.js +309 -0
  221. package/locale-data/es-SV.js +309 -0
  222. package/locale-data/es-US.js +309 -0
  223. package/locale-data/es-UY.js +309 -0
  224. package/locale-data/es-VE.js +309 -0
  225. package/locale-data/es.js +309 -0
  226. package/locale-data/et.js +309 -0
  227. package/locale-data/eu.js +309 -0
  228. package/locale-data/ewo.js +255 -0
  229. package/locale-data/fa-AF.js +309 -0
  230. package/locale-data/fa.js +309 -0
  231. package/locale-data/ff-Adlm-BF.js +303 -0
  232. package/locale-data/ff-Adlm-CM.js +303 -0
  233. package/locale-data/ff-Adlm-GH.js +303 -0
  234. package/locale-data/ff-Adlm-GM.js +303 -0
  235. package/locale-data/ff-Adlm-GW.js +303 -0
  236. package/locale-data/ff-Adlm-LR.js +303 -0
  237. package/locale-data/ff-Adlm-MR.js +303 -0
  238. package/locale-data/ff-Adlm-NE.js +303 -0
  239. package/locale-data/ff-Adlm-NG.js +303 -0
  240. package/locale-data/ff-Adlm-SL.js +303 -0
  241. package/locale-data/ff-Adlm-SN.js +303 -0
  242. package/locale-data/ff-Adlm.js +303 -0
  243. package/locale-data/ff-Latn-BF.js +255 -0
  244. package/locale-data/ff-Latn-CM.js +255 -0
  245. package/locale-data/ff-Latn-GH.js +255 -0
  246. package/locale-data/ff-Latn-GM.js +255 -0
  247. package/locale-data/ff-Latn-GN.js +255 -0
  248. package/locale-data/ff-Latn-GW.js +255 -0
  249. package/locale-data/ff-Latn-LR.js +255 -0
  250. package/locale-data/ff-Latn-MR.js +255 -0
  251. package/locale-data/ff-Latn-NE.js +255 -0
  252. package/locale-data/ff-Latn-NG.js +255 -0
  253. package/locale-data/ff-Latn-SL.js +255 -0
  254. package/locale-data/ff-Latn.js +255 -0
  255. package/locale-data/ff.js +255 -0
  256. package/locale-data/fi.js +309 -0
  257. package/locale-data/fil.js +309 -0
  258. package/locale-data/fo-DK.js +309 -0
  259. package/locale-data/fo.js +309 -0
  260. package/locale-data/fr-BE.js +309 -0
  261. package/locale-data/fr-BF.js +309 -0
  262. package/locale-data/fr-BI.js +309 -0
  263. package/locale-data/fr-BJ.js +309 -0
  264. package/locale-data/fr-BL.js +309 -0
  265. package/locale-data/fr-CA.js +309 -0
  266. package/locale-data/fr-CD.js +309 -0
  267. package/locale-data/fr-CF.js +309 -0
  268. package/locale-data/fr-CG.js +309 -0
  269. package/locale-data/fr-CH.js +309 -0
  270. package/locale-data/fr-CI.js +309 -0
  271. package/locale-data/fr-CM.js +309 -0
  272. package/locale-data/fr-DJ.js +309 -0
  273. package/locale-data/fr-DZ.js +309 -0
  274. package/locale-data/fr-GA.js +309 -0
  275. package/locale-data/fr-GF.js +309 -0
  276. package/locale-data/fr-GN.js +309 -0
  277. package/locale-data/fr-GP.js +309 -0
  278. package/locale-data/fr-GQ.js +309 -0
  279. package/locale-data/fr-HT.js +309 -0
  280. package/locale-data/fr-KM.js +309 -0
  281. package/locale-data/fr-LU.js +309 -0
  282. package/locale-data/fr-MA.js +309 -0
  283. package/locale-data/fr-MC.js +309 -0
  284. package/locale-data/fr-MF.js +309 -0
  285. package/locale-data/fr-MG.js +309 -0
  286. package/locale-data/fr-ML.js +309 -0
  287. package/locale-data/fr-MQ.js +309 -0
  288. package/locale-data/fr-MR.js +309 -0
  289. package/locale-data/fr-MU.js +309 -0
  290. package/locale-data/fr-NC.js +309 -0
  291. package/locale-data/fr-NE.js +309 -0
  292. package/locale-data/fr-PF.js +309 -0
  293. package/locale-data/fr-PM.js +309 -0
  294. package/locale-data/fr-RE.js +309 -0
  295. package/locale-data/fr-RW.js +309 -0
  296. package/locale-data/fr-SC.js +309 -0
  297. package/locale-data/fr-SN.js +309 -0
  298. package/locale-data/fr-SY.js +309 -0
  299. package/locale-data/fr-TD.js +309 -0
  300. package/locale-data/fr-TG.js +309 -0
  301. package/locale-data/fr-TN.js +309 -0
  302. package/locale-data/fr-VU.js +309 -0
  303. package/locale-data/fr-WF.js +309 -0
  304. package/locale-data/fr-YT.js +309 -0
  305. package/locale-data/fr.js +309 -0
  306. package/locale-data/fur.js +303 -0
  307. package/locale-data/fy.js +303 -0
  308. package/locale-data/ga-GB.js +453 -0
  309. package/locale-data/ga.js +453 -0
  310. package/locale-data/gd.js +411 -0
  311. package/locale-data/gl.js +309 -0
  312. package/locale-data/gsw-FR.js +261 -0
  313. package/locale-data/gsw-LI.js +261 -0
  314. package/locale-data/gsw.js +261 -0
  315. package/locale-data/gu.js +309 -0
  316. package/locale-data/guz.js +255 -0
  317. package/locale-data/gv.js +255 -0
  318. package/locale-data/ha-GH.js +303 -0
  319. package/locale-data/ha-NE.js +303 -0
  320. package/locale-data/ha.js +303 -0
  321. package/locale-data/haw.js +255 -0
  322. package/locale-data/he.js +379 -0
  323. package/locale-data/hi.js +309 -0
  324. package/locale-data/hr-BA.js +357 -0
  325. package/locale-data/hr.js +357 -0
  326. package/locale-data/hsb.js +399 -0
  327. package/locale-data/hu.js +309 -0
  328. package/locale-data/hy.js +309 -0
  329. package/locale-data/ia.js +303 -0
  330. package/locale-data/id.js +261 -0
  331. package/locale-data/ig.js +255 -0
  332. package/locale-data/ii.js +261 -0
  333. package/locale-data/is.js +309 -0
  334. package/locale-data/it-CH.js +309 -0
  335. package/locale-data/it-SM.js +309 -0
  336. package/locale-data/it-VA.js +309 -0
  337. package/locale-data/it.js +309 -0
  338. package/locale-data/ja.js +261 -0
  339. package/locale-data/jgo.js +291 -0
  340. package/locale-data/jmc.js +255 -0
  341. package/locale-data/jv.js +255 -0
  342. package/locale-data/ka.js +309 -0
  343. package/locale-data/kab.js +255 -0
  344. package/locale-data/kam.js +255 -0
  345. package/locale-data/kde.js +255 -0
  346. package/locale-data/kea.js +255 -0
  347. package/locale-data/kgp.js +277 -0
  348. package/locale-data/khq.js +255 -0
  349. package/locale-data/ki.js +255 -0
  350. package/locale-data/kk.js +309 -0
  351. package/locale-data/kkj.js +255 -0
  352. package/locale-data/kl.js +297 -0
  353. package/locale-data/kln.js +255 -0
  354. package/locale-data/km.js +261 -0
  355. package/locale-data/kn.js +309 -0
  356. package/locale-data/ko-KP.js +261 -0
  357. package/locale-data/ko.js +261 -0
  358. package/locale-data/kok.js +303 -0
  359. package/locale-data/ks-Arab.js +255 -0
  360. package/locale-data/ks.js +255 -0
  361. package/locale-data/ksb.js +255 -0
  362. package/locale-data/ksf.js +255 -0
  363. package/locale-data/ksh.js +273 -0
  364. package/locale-data/ku.js +303 -0
  365. package/locale-data/kw.js +255 -0
  366. package/locale-data/ky.js +309 -0
  367. package/locale-data/lag.js +255 -0
  368. package/locale-data/lb.js +303 -0
  369. package/locale-data/lg.js +255 -0
  370. package/locale-data/lkt.js +255 -0
  371. package/locale-data/ln-AO.js +255 -0
  372. package/locale-data/ln-CF.js +255 -0
  373. package/locale-data/ln-CG.js +255 -0
  374. package/locale-data/ln.js +255 -0
  375. package/locale-data/lo.js +261 -0
  376. package/locale-data/lrc-IQ.js +255 -0
  377. package/locale-data/lrc.js +255 -0
  378. package/locale-data/lt.js +405 -0
  379. package/locale-data/lu.js +255 -0
  380. package/locale-data/luo.js +255 -0
  381. package/locale-data/luy.js +255 -0
  382. package/locale-data/lv.js +357 -0
  383. package/locale-data/mai.js +255 -0
  384. package/locale-data/mas-TZ.js +255 -0
  385. package/locale-data/mas.js +255 -0
  386. package/locale-data/mer.js +255 -0
  387. package/locale-data/mfe.js +255 -0
  388. package/locale-data/mg.js +255 -0
  389. package/locale-data/mgh.js +255 -0
  390. package/locale-data/mgo.js +258 -0
  391. package/locale-data/mi.js +255 -0
  392. package/locale-data/mk.js +309 -0
  393. package/locale-data/ml.js +309 -0
  394. package/locale-data/mn.js +309 -0
  395. package/locale-data/mni-Beng.js +255 -0
  396. package/locale-data/mni.js +255 -0
  397. package/locale-data/mr.js +303 -0
  398. package/locale-data/ms-BN.js +261 -0
  399. package/locale-data/ms-ID.js +261 -0
  400. package/locale-data/ms-SG.js +261 -0
  401. package/locale-data/ms.js +261 -0
  402. package/locale-data/mt.js +447 -0
  403. package/locale-data/mua.js +255 -0
  404. package/locale-data/my.js +261 -0
  405. package/locale-data/mzn.js +255 -0
  406. package/locale-data/naq.js +255 -0
  407. package/locale-data/nb-SJ.js +309 -0
  408. package/locale-data/nb.js +309 -0
  409. package/locale-data/nd.js +255 -0
  410. package/locale-data/nds-NL.js +255 -0
  411. package/locale-data/nds.js +255 -0
  412. package/locale-data/ne-IN.js +309 -0
  413. package/locale-data/ne.js +309 -0
  414. package/locale-data/nl-AW.js +309 -0
  415. package/locale-data/nl-BE.js +309 -0
  416. package/locale-data/nl-BQ.js +309 -0
  417. package/locale-data/nl-CW.js +309 -0
  418. package/locale-data/nl-SR.js +309 -0
  419. package/locale-data/nl-SX.js +309 -0
  420. package/locale-data/nl.js +309 -0
  421. package/locale-data/nmg.js +255 -0
  422. package/locale-data/nn.js +309 -0
  423. package/locale-data/nnh.js +255 -0
  424. package/locale-data/no.js +309 -0
  425. package/locale-data/nus.js +255 -0
  426. package/locale-data/nyn.js +255 -0
  427. package/locale-data/om-KE.js +303 -0
  428. package/locale-data/om.js +303 -0
  429. package/locale-data/or.js +303 -0
  430. package/locale-data/os-RU.js +273 -0
  431. package/locale-data/os.js +273 -0
  432. package/locale-data/pa-Arab.js +255 -0
  433. package/locale-data/pa-Guru.js +303 -0
  434. package/locale-data/pa.js +303 -0
  435. package/locale-data/pcm.js +303 -0
  436. package/locale-data/pl.js +405 -0
  437. package/locale-data/ps-PK.js +303 -0
  438. package/locale-data/ps.js +303 -0
  439. package/locale-data/pt-AO.js +309 -0
  440. package/locale-data/pt-CH.js +309 -0
  441. package/locale-data/pt-CV.js +309 -0
  442. package/locale-data/pt-GQ.js +309 -0
  443. package/locale-data/pt-GW.js +309 -0
  444. package/locale-data/pt-LU.js +309 -0
  445. package/locale-data/pt-MO.js +309 -0
  446. package/locale-data/pt-MZ.js +309 -0
  447. package/locale-data/pt-PT.js +309 -0
  448. package/locale-data/pt-ST.js +309 -0
  449. package/locale-data/pt-TL.js +309 -0
  450. package/locale-data/pt.js +309 -0
  451. package/locale-data/qu-BO.js +255 -0
  452. package/locale-data/qu-EC.js +255 -0
  453. package/locale-data/qu.js +255 -0
  454. package/locale-data/rm.js +309 -0
  455. package/locale-data/rn.js +255 -0
  456. package/locale-data/ro-MD.js +357 -0
  457. package/locale-data/ro.js +357 -0
  458. package/locale-data/rof.js +255 -0
  459. package/locale-data/ru-BY.js +405 -0
  460. package/locale-data/ru-KG.js +405 -0
  461. package/locale-data/ru-KZ.js +405 -0
  462. package/locale-data/ru-MD.js +405 -0
  463. package/locale-data/ru-UA.js +405 -0
  464. package/locale-data/ru.js +405 -0
  465. package/locale-data/rw.js +255 -0
  466. package/locale-data/rwk.js +255 -0
  467. package/locale-data/sa.js +255 -0
  468. package/locale-data/sah.js +261 -0
  469. package/locale-data/saq.js +255 -0
  470. package/locale-data/sat-Olck.js +255 -0
  471. package/locale-data/sat.js +255 -0
  472. package/locale-data/sbp.js +255 -0
  473. package/locale-data/sc.js +303 -0
  474. package/locale-data/sd-Arab.js +303 -0
  475. package/locale-data/sd-Deva.js +255 -0
  476. package/locale-data/sd.js +303 -0
  477. package/locale-data/se-FI.js +357 -0
  478. package/locale-data/se-SE.js +345 -0
  479. package/locale-data/se.js +345 -0
  480. package/locale-data/seh.js +255 -0
  481. package/locale-data/ses.js +255 -0
  482. package/locale-data/sg.js +255 -0
  483. package/locale-data/shi-Latn.js +255 -0
  484. package/locale-data/shi-Tfng.js +255 -0
  485. package/locale-data/shi.js +255 -0
  486. package/locale-data/si.js +309 -0
  487. package/locale-data/sk.js +405 -0
  488. package/locale-data/sl.js +405 -0
  489. package/locale-data/smn.js +255 -0
  490. package/locale-data/sn.js +255 -0
  491. package/locale-data/so-DJ.js +303 -0
  492. package/locale-data/so-ET.js +303 -0
  493. package/locale-data/so-KE.js +303 -0
  494. package/locale-data/so.js +303 -0
  495. package/locale-data/sq-MK.js +303 -0
  496. package/locale-data/sq-XK.js +303 -0
  497. package/locale-data/sq.js +303 -0
  498. package/locale-data/sr-Cyrl-BA.js +357 -0
  499. package/locale-data/sr-Cyrl-ME.js +357 -0
  500. package/locale-data/sr-Cyrl-XK.js +357 -0
  501. package/locale-data/sr-Cyrl.js +357 -0
  502. package/locale-data/sr-Latn-BA.js +357 -0
  503. package/locale-data/sr-Latn-ME.js +357 -0
  504. package/locale-data/sr-Latn-XK.js +357 -0
  505. package/locale-data/sr-Latn.js +357 -0
  506. package/locale-data/sr.js +357 -0
  507. package/locale-data/su-Latn.js +255 -0
  508. package/locale-data/su.js +255 -0
  509. package/locale-data/sv-AX.js +309 -0
  510. package/locale-data/sv-FI.js +309 -0
  511. package/locale-data/sv.js +309 -0
  512. package/locale-data/sw-CD.js +309 -0
  513. package/locale-data/sw-KE.js +309 -0
  514. package/locale-data/sw-UG.js +309 -0
  515. package/locale-data/sw.js +309 -0
  516. package/locale-data/ta-LK.js +309 -0
  517. package/locale-data/ta-MY.js +309 -0
  518. package/locale-data/ta-SG.js +309 -0
  519. package/locale-data/ta.js +309 -0
  520. package/locale-data/te.js +309 -0
  521. package/locale-data/teo-KE.js +255 -0
  522. package/locale-data/teo.js +255 -0
  523. package/locale-data/tg.js +255 -0
  524. package/locale-data/th.js +261 -0
  525. package/locale-data/ti-ER.js +303 -0
  526. package/locale-data/ti.js +303 -0
  527. package/locale-data/tk.js +303 -0
  528. package/locale-data/to.js +261 -0
  529. package/locale-data/tr-CY.js +309 -0
  530. package/locale-data/tr.js +309 -0
  531. package/locale-data/tt.js +255 -0
  532. package/locale-data/twq.js +255 -0
  533. package/locale-data/tzm.js +255 -0
  534. package/locale-data/ug.js +297 -0
  535. package/locale-data/uk.js +405 -0
  536. package/locale-data/und.js +255 -0
  537. package/locale-data/ur-IN.js +309 -0
  538. package/locale-data/ur.js +309 -0
  539. package/locale-data/uz-Arab.js +255 -0
  540. package/locale-data/uz-Cyrl.js +297 -0
  541. package/locale-data/uz-Latn.js +303 -0
  542. package/locale-data/uz.js +303 -0
  543. package/locale-data/vai-Latn.js +255 -0
  544. package/locale-data/vai-Vaii.js +255 -0
  545. package/locale-data/vai.js +255 -0
  546. package/locale-data/vi.js +261 -0
  547. package/locale-data/vun.js +255 -0
  548. package/locale-data/wae.js +303 -0
  549. package/locale-data/wo.js +255 -0
  550. package/locale-data/xh.js +255 -0
  551. package/locale-data/xog.js +255 -0
  552. package/locale-data/yav.js +255 -0
  553. package/locale-data/yi.js +270 -0
  554. package/locale-data/yo-BJ.js +261 -0
  555. package/locale-data/yo.js +261 -0
  556. package/locale-data/yrl-CO.js +309 -0
  557. package/locale-data/yrl-VE.js +309 -0
  558. package/locale-data/yrl.js +309 -0
  559. package/locale-data/yue-Hans.js +261 -0
  560. package/locale-data/yue-Hant.js +261 -0
  561. package/locale-data/yue.js +261 -0
  562. package/locale-data/zgh.js +255 -0
  563. package/locale-data/zh-Hans-HK.js +261 -0
  564. package/locale-data/zh-Hans-MO.js +261 -0
  565. package/locale-data/zh-Hans-SG.js +261 -0
  566. package/locale-data/zh-Hans.js +261 -0
  567. package/locale-data/zh-Hant-HK.js +261 -0
  568. package/locale-data/zh-Hant-MO.js +261 -0
  569. package/locale-data/zh-Hant.js +261 -0
  570. package/locale-data/zh.js +261 -0
  571. package/locale-data/zu.js +309 -0
  572. package/package.json +6 -7
  573. package/polyfill-force.js +6 -0
  574. package/polyfill.iife.js +588 -2326
  575. package/polyfill.js +6 -0
package/polyfill.iife.js CHANGED
@@ -11,2371 +11,646 @@
11
11
  return Intl.getCanonicalLocales(locales);
12
12
  }
13
13
 
14
- // node_modules/.aspect_rules_js/decimal.js@10.6.0/node_modules/decimal.js/decimal.mjs
15
- var EXP_LIMIT = 9e15;
16
- var MAX_DIGITS = 1e9;
17
- var NUMERALS = "0123456789abcdef";
18
- var LN10 = "2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058";
19
- var PI = "3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789";
20
- var DEFAULTS = {
21
- // These values must be integers within the stated ranges (inclusive).
22
- // Most of these values can be changed at run-time using the `Decimal.config` method.
23
- // The maximum number of significant digits of the result of a calculation or base conversion.
24
- // E.g. `Decimal.config({ precision: 20 });`
25
- precision: 20,
26
- // 1 to MAX_DIGITS
27
- // The rounding mode used when rounding to `precision`.
28
- //
29
- // ROUND_UP 0 Away from zero.
30
- // ROUND_DOWN 1 Towards zero.
31
- // ROUND_CEIL 2 Towards +Infinity.
32
- // ROUND_FLOOR 3 Towards -Infinity.
33
- // ROUND_HALF_UP 4 Towards nearest neighbour. If equidistant, up.
34
- // ROUND_HALF_DOWN 5 Towards nearest neighbour. If equidistant, down.
35
- // ROUND_HALF_EVEN 6 Towards nearest neighbour. If equidistant, towards even neighbour.
36
- // ROUND_HALF_CEIL 7 Towards nearest neighbour. If equidistant, towards +Infinity.
37
- // ROUND_HALF_FLOOR 8 Towards nearest neighbour. If equidistant, towards -Infinity.
38
- //
39
- // E.g.
40
- // `Decimal.rounding = 4;`
41
- // `Decimal.rounding = Decimal.ROUND_HALF_UP;`
42
- rounding: 4,
43
- // 0 to 8
44
- // The modulo mode used when calculating the modulus: a mod n.
45
- // The quotient (q = a / n) is calculated according to the corresponding rounding mode.
46
- // The remainder (r) is calculated as: r = a - n * q.
47
- //
48
- // UP 0 The remainder is positive if the dividend is negative, else is negative.
49
- // DOWN 1 The remainder has the same sign as the dividend (JavaScript %).
50
- // FLOOR 3 The remainder has the same sign as the divisor (Python %).
51
- // HALF_EVEN 6 The IEEE 754 remainder function.
52
- // EUCLID 9 Euclidian division. q = sign(n) * floor(a / abs(n)). Always positive.
53
- //
54
- // Truncated division (1), floored division (3), the IEEE 754 remainder (6), and Euclidian
55
- // division (9) are commonly used for the modulus operation. The other rounding modes can also
56
- // be used, but they may not give useful results.
57
- modulo: 1,
58
- // 0 to 9
59
- // The exponent value at and beneath which `toString` returns exponential notation.
60
- // JavaScript numbers: -7
61
- toExpNeg: -7,
62
- // 0 to -EXP_LIMIT
63
- // The exponent value at and above which `toString` returns exponential notation.
64
- // JavaScript numbers: 21
65
- toExpPos: 21,
66
- // 0 to EXP_LIMIT
67
- // The minimum exponent value, beneath which underflow to zero occurs.
68
- // JavaScript numbers: -324 (5e-324)
69
- minE: -EXP_LIMIT,
70
- // -1 to -EXP_LIMIT
71
- // The maximum exponent value, above which overflow to Infinity occurs.
72
- // JavaScript numbers: 308 (1.7976931348623157e+308)
73
- maxE: EXP_LIMIT,
74
- // 1 to EXP_LIMIT
75
- // Whether to use cryptographically-secure random number generation, if available.
76
- crypto: false
77
- // true/false
78
- };
79
- var inexact;
80
- var quadrant;
81
- var external = true;
82
- var decimalError = "[DecimalError] ";
83
- var invalidArgument = decimalError + "Invalid argument: ";
84
- var precisionLimitExceeded = decimalError + "Precision limit exceeded";
85
- var cryptoUnavailable = decimalError + "crypto unavailable";
86
- var tag = "[object Decimal]";
87
- var mathfloor = Math.floor;
88
- var mathpow = Math.pow;
89
- var isBinary = /^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i;
90
- var isHex = /^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i;
91
- var isOctal = /^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i;
92
- var isDecimal = /^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;
93
- var BASE = 1e7;
94
- var LOG_BASE = 7;
95
- var MAX_SAFE_INTEGER = 9007199254740991;
96
- var LN10_PRECISION = LN10.length - 1;
97
- var PI_PRECISION = PI.length - 1;
98
- var P = { toStringTag: tag };
99
- P.absoluteValue = P.abs = function() {
100
- var x = new this.constructor(this);
101
- if (x.s < 0)
102
- x.s = 1;
103
- return finalise(x);
104
- };
105
- P.ceil = function() {
106
- return finalise(new this.constructor(this), this.e + 1, 2);
107
- };
108
- P.clampedTo = P.clamp = function(min2, max2) {
109
- var k, x = this, Ctor = x.constructor;
110
- min2 = new Ctor(min2);
111
- max2 = new Ctor(max2);
112
- if (!min2.s || !max2.s)
113
- return new Ctor(NaN);
114
- if (min2.gt(max2))
115
- throw Error(invalidArgument + max2);
116
- k = x.cmp(min2);
117
- return k < 0 ? min2 : x.cmp(max2) > 0 ? max2 : new Ctor(x);
118
- };
119
- P.comparedTo = P.cmp = function(y) {
120
- var i, j, xdL, ydL, x = this, xd = x.d, yd = (y = new x.constructor(y)).d, xs = x.s, ys = y.s;
121
- if (!xd || !yd) {
122
- return !xs || !ys ? NaN : xs !== ys ? xs : xd === yd ? 0 : !xd ^ xs < 0 ? 1 : -1;
123
- }
124
- if (!xd[0] || !yd[0])
125
- return xd[0] ? xs : yd[0] ? -ys : 0;
126
- if (xs !== ys)
127
- return xs;
128
- if (x.e !== y.e)
129
- return x.e > y.e ^ xs < 0 ? 1 : -1;
130
- xdL = xd.length;
131
- ydL = yd.length;
132
- for (i = 0, j = xdL < ydL ? xdL : ydL; i < j; ++i) {
133
- if (xd[i] !== yd[i])
134
- return xd[i] > yd[i] ^ xs < 0 ? 1 : -1;
135
- }
136
- return xdL === ydL ? 0 : xdL > ydL ^ xs < 0 ? 1 : -1;
137
- };
138
- P.cosine = P.cos = function() {
139
- var pr, rm, x = this, Ctor = x.constructor;
140
- if (!x.d)
141
- return new Ctor(NaN);
142
- if (!x.d[0])
143
- return new Ctor(1);
144
- pr = Ctor.precision;
145
- rm = Ctor.rounding;
146
- Ctor.precision = pr + Math.max(x.e, x.sd()) + LOG_BASE;
147
- Ctor.rounding = 1;
148
- x = cosine(Ctor, toLessThanHalfPi(Ctor, x));
149
- Ctor.precision = pr;
150
- Ctor.rounding = rm;
151
- return finalise(quadrant == 2 || quadrant == 3 ? x.neg() : x, pr, rm, true);
152
- };
153
- P.cubeRoot = P.cbrt = function() {
154
- var e, m, n, r, rep, s, sd, t, t3, t3plusx, x = this, Ctor = x.constructor;
155
- if (!x.isFinite() || x.isZero())
156
- return new Ctor(x);
157
- external = false;
158
- s = x.s * mathpow(x.s * x, 1 / 3);
159
- if (!s || Math.abs(s) == 1 / 0) {
160
- n = digitsToString(x.d);
161
- e = x.e;
162
- if (s = (e - n.length + 1) % 3)
163
- n += s == 1 || s == -2 ? "0" : "00";
164
- s = mathpow(n, 1 / 3);
165
- e = mathfloor((e + 1) / 3) - (e % 3 == (e < 0 ? -1 : 2));
166
- if (s == 1 / 0) {
167
- n = "5e" + e;
168
- } else {
169
- n = s.toExponential();
170
- n = n.slice(0, n.indexOf("e") + 1) + e;
171
- }
172
- r = new Ctor(n);
173
- r.s = x.s;
174
- } else {
175
- r = new Ctor(s.toString());
176
- }
177
- sd = (e = Ctor.precision) + 3;
178
- for (; ; ) {
179
- t = r;
180
- t3 = t.times(t).times(t);
181
- t3plusx = t3.plus(x);
182
- r = divide(t3plusx.plus(x).times(t), t3plusx.plus(t3), sd + 2, 1);
183
- if (digitsToString(t.d).slice(0, sd) === (n = digitsToString(r.d)).slice(0, sd)) {
184
- n = n.slice(sd - 3, sd + 1);
185
- if (n == "9999" || !rep && n == "4999") {
186
- if (!rep) {
187
- finalise(t, e + 1, 0);
188
- if (t.times(t).times(t).eq(x)) {
189
- r = t;
190
- break;
191
- }
192
- }
193
- sd += 4;
194
- rep = 1;
195
- } else {
196
- if (!+n || !+n.slice(1) && n.charAt(0) == "5") {
197
- finalise(r, e + 1, 1);
198
- m = !r.times(r).times(r).eq(x);
199
- }
200
- break;
201
- }
202
- }
14
+ // node_modules/.aspect_rules_js/@formatjs+bigdecimal@0.0.0/node_modules/@formatjs/bigdecimal/index.js
15
+ var DIV_PRECISION = 40;
16
+ var SpecialValue = function(SpecialValue2) {
17
+ SpecialValue2[SpecialValue2["NONE"] = 0] = "NONE";
18
+ SpecialValue2[SpecialValue2["NAN"] = 1] = "NAN";
19
+ SpecialValue2[SpecialValue2["POSITIVE_INFINITY"] = 2] = "POSITIVE_INFINITY";
20
+ SpecialValue2[SpecialValue2["NEGATIVE_INFINITY"] = 3] = "NEGATIVE_INFINITY";
21
+ return SpecialValue2;
22
+ }(SpecialValue || {});
23
+ function removeTrailingZeros(mantissa, exponent) {
24
+ if (mantissa === 0n)
25
+ return [0n, 0];
26
+ while (mantissa % 10n === 0n) {
27
+ mantissa /= 10n;
28
+ exponent++;
29
+ }
30
+ return [mantissa, exponent];
31
+ }
32
+ function bigintAbs(n) {
33
+ return n < 0n ? -n : n;
34
+ }
35
+ function digitCount(n) {
36
+ if (n === 0n)
37
+ return 1;
38
+ if (n < 0n)
39
+ n = -n;
40
+ let count = 0;
41
+ const big15 = 1000000000000000n;
42
+ while (n >= big15) {
43
+ n /= big15;
44
+ count += 15;
45
+ }
46
+ let r = Number(n);
47
+ while (r >= 1) {
48
+ r /= 10;
49
+ count++;
50
+ }
51
+ return count;
52
+ }
53
+ var TEN_BIGINT = 10n;
54
+ function bigintPow10(n) {
55
+ if (n <= 0)
56
+ return 1n;
57
+ let result = 1n;
58
+ let base = TEN_BIGINT;
59
+ let exp = n;
60
+ while (exp > 0) {
61
+ if (exp & 1)
62
+ result *= base;
63
+ base *= base;
64
+ exp >>= 1;
203
65
  }
204
- external = true;
205
- return finalise(r, e, Ctor.rounding, m);
206
- };
207
- P.decimalPlaces = P.dp = function() {
208
- var w, d = this.d, n = NaN;
209
- if (d) {
210
- w = d.length - 1;
211
- n = (w - mathfloor(this.e / LOG_BASE)) * LOG_BASE;
212
- w = d[w];
213
- if (w)
214
- for (; w % 10 == 0; w /= 10)
215
- n--;
216
- if (n < 0)
217
- n = 0;
66
+ return result;
67
+ }
68
+ function parseDecimalString(s) {
69
+ s = s.trim();
70
+ if (s === "NaN") {
71
+ return {
72
+ mantissa: 0n,
73
+ exponent: 0,
74
+ special: SpecialValue.NAN,
75
+ negativeZero: false
76
+ };
218
77
  }
219
- return n;
220
- };
221
- P.dividedBy = P.div = function(y) {
222
- return divide(this, new this.constructor(y));
223
- };
224
- P.dividedToIntegerBy = P.divToInt = function(y) {
225
- var x = this, Ctor = x.constructor;
226
- return finalise(divide(x, new Ctor(y), 0, 1, 1), Ctor.precision, Ctor.rounding);
227
- };
228
- P.equals = P.eq = function(y) {
229
- return this.cmp(y) === 0;
230
- };
231
- P.floor = function() {
232
- return finalise(new this.constructor(this), this.e + 1, 3);
233
- };
234
- P.greaterThan = P.gt = function(y) {
235
- return this.cmp(y) > 0;
236
- };
237
- P.greaterThanOrEqualTo = P.gte = function(y) {
238
- var k = this.cmp(y);
239
- return k == 1 || k === 0;
240
- };
241
- P.hyperbolicCosine = P.cosh = function() {
242
- var k, n, pr, rm, len, x = this, Ctor = x.constructor, one = new Ctor(1);
243
- if (!x.isFinite())
244
- return new Ctor(x.s ? 1 / 0 : NaN);
245
- if (x.isZero())
246
- return one;
247
- pr = Ctor.precision;
248
- rm = Ctor.rounding;
249
- Ctor.precision = pr + Math.max(x.e, x.sd()) + 4;
250
- Ctor.rounding = 1;
251
- len = x.d.length;
252
- if (len < 32) {
253
- k = Math.ceil(len / 3);
254
- n = (1 / tinyPow(4, k)).toString();
255
- } else {
256
- k = 16;
257
- n = "2.3283064365386962890625e-10";
78
+ if (s === "Infinity" || s === "+Infinity") {
79
+ return {
80
+ mantissa: 0n,
81
+ exponent: 0,
82
+ special: SpecialValue.POSITIVE_INFINITY,
83
+ negativeZero: false
84
+ };
258
85
  }
259
- x = taylorSeries(Ctor, 1, x.times(n), new Ctor(1), true);
260
- var cosh2_x, i = k, d8 = new Ctor(8);
261
- for (; i--; ) {
262
- cosh2_x = x.times(x);
263
- x = one.minus(cosh2_x.times(d8.minus(cosh2_x.times(d8))));
86
+ if (s === "-Infinity") {
87
+ return {
88
+ mantissa: 0n,
89
+ exponent: 0,
90
+ special: SpecialValue.NEGATIVE_INFINITY,
91
+ negativeZero: false
92
+ };
264
93
  }
265
- return finalise(x, Ctor.precision = pr, Ctor.rounding = rm, true);
266
- };
267
- P.hyperbolicSine = P.sinh = function() {
268
- var k, pr, rm, len, x = this, Ctor = x.constructor;
269
- if (!x.isFinite() || x.isZero())
270
- return new Ctor(x);
271
- pr = Ctor.precision;
272
- rm = Ctor.rounding;
273
- Ctor.precision = pr + Math.max(x.e, x.sd()) + 4;
274
- Ctor.rounding = 1;
275
- len = x.d.length;
276
- if (len < 3) {
277
- x = taylorSeries(Ctor, 2, x, x, true);
94
+ let negative = false;
95
+ let idx = 0;
96
+ if (s[idx] === "-") {
97
+ negative = true;
98
+ idx++;
99
+ } else if (s[idx] === "+") {
100
+ idx++;
101
+ }
102
+ let eIdx = s.indexOf("e", idx);
103
+ if (eIdx === -1)
104
+ eIdx = s.indexOf("E", idx);
105
+ let sciExp = 0;
106
+ let numPart;
107
+ if (eIdx !== -1) {
108
+ sciExp = parseInt(s.substring(eIdx + 1), 10);
109
+ numPart = s.substring(idx, eIdx);
278
110
  } else {
279
- k = 1.4 * Math.sqrt(len);
280
- k = k > 16 ? 16 : k | 0;
281
- x = x.times(1 / tinyPow(5, k));
282
- x = taylorSeries(Ctor, 2, x, x, true);
283
- var sinh2_x, d5 = new Ctor(5), d16 = new Ctor(16), d20 = new Ctor(20);
284
- for (; k--; ) {
285
- sinh2_x = x.times(x);
286
- x = x.times(d5.plus(sinh2_x.times(d16.times(sinh2_x).plus(d20))));
287
- }
288
- }
289
- Ctor.precision = pr;
290
- Ctor.rounding = rm;
291
- return finalise(x, pr, rm, true);
292
- };
293
- P.hyperbolicTangent = P.tanh = function() {
294
- var pr, rm, x = this, Ctor = x.constructor;
295
- if (!x.isFinite())
296
- return new Ctor(x.s);
297
- if (x.isZero())
298
- return new Ctor(x);
299
- pr = Ctor.precision;
300
- rm = Ctor.rounding;
301
- Ctor.precision = pr + 7;
302
- Ctor.rounding = 1;
303
- return divide(x.sinh(), x.cosh(), Ctor.precision = pr, Ctor.rounding = rm);
304
- };
305
- P.inverseCosine = P.acos = function() {
306
- var x = this, Ctor = x.constructor, k = x.abs().cmp(1), pr = Ctor.precision, rm = Ctor.rounding;
307
- if (k !== -1) {
308
- return k === 0 ? x.isNeg() ? getPi(Ctor, pr, rm) : new Ctor(0) : new Ctor(NaN);
309
- }
310
- if (x.isZero())
311
- return getPi(Ctor, pr + 4, rm).times(0.5);
312
- Ctor.precision = pr + 6;
313
- Ctor.rounding = 1;
314
- x = new Ctor(1).minus(x).div(x.plus(1)).sqrt().atan();
315
- Ctor.precision = pr;
316
- Ctor.rounding = rm;
317
- return x.times(2);
318
- };
319
- P.inverseHyperbolicCosine = P.acosh = function() {
320
- var pr, rm, x = this, Ctor = x.constructor;
321
- if (x.lte(1))
322
- return new Ctor(x.eq(1) ? 0 : NaN);
323
- if (!x.isFinite())
324
- return new Ctor(x);
325
- pr = Ctor.precision;
326
- rm = Ctor.rounding;
327
- Ctor.precision = pr + Math.max(Math.abs(x.e), x.sd()) + 4;
328
- Ctor.rounding = 1;
329
- external = false;
330
- x = x.times(x).minus(1).sqrt().plus(x);
331
- external = true;
332
- Ctor.precision = pr;
333
- Ctor.rounding = rm;
334
- return x.ln();
335
- };
336
- P.inverseHyperbolicSine = P.asinh = function() {
337
- var pr, rm, x = this, Ctor = x.constructor;
338
- if (!x.isFinite() || x.isZero())
339
- return new Ctor(x);
340
- pr = Ctor.precision;
341
- rm = Ctor.rounding;
342
- Ctor.precision = pr + 2 * Math.max(Math.abs(x.e), x.sd()) + 6;
343
- Ctor.rounding = 1;
344
- external = false;
345
- x = x.times(x).plus(1).sqrt().plus(x);
346
- external = true;
347
- Ctor.precision = pr;
348
- Ctor.rounding = rm;
349
- return x.ln();
350
- };
351
- P.inverseHyperbolicTangent = P.atanh = function() {
352
- var pr, rm, wpr, xsd, x = this, Ctor = x.constructor;
353
- if (!x.isFinite())
354
- return new Ctor(NaN);
355
- if (x.e >= 0)
356
- return new Ctor(x.abs().eq(1) ? x.s / 0 : x.isZero() ? x : NaN);
357
- pr = Ctor.precision;
358
- rm = Ctor.rounding;
359
- xsd = x.sd();
360
- if (Math.max(xsd, pr) < 2 * -x.e - 1)
361
- return finalise(new Ctor(x), pr, rm, true);
362
- Ctor.precision = wpr = xsd - x.e;
363
- x = divide(x.plus(1), new Ctor(1).minus(x), wpr + pr, 1);
364
- Ctor.precision = pr + 4;
365
- Ctor.rounding = 1;
366
- x = x.ln();
367
- Ctor.precision = pr;
368
- Ctor.rounding = rm;
369
- return x.times(0.5);
370
- };
371
- P.inverseSine = P.asin = function() {
372
- var halfPi, k, pr, rm, x = this, Ctor = x.constructor;
373
- if (x.isZero())
374
- return new Ctor(x);
375
- k = x.abs().cmp(1);
376
- pr = Ctor.precision;
377
- rm = Ctor.rounding;
378
- if (k !== -1) {
379
- if (k === 0) {
380
- halfPi = getPi(Ctor, pr + 4, rm).times(0.5);
381
- halfPi.s = x.s;
382
- return halfPi;
383
- }
384
- return new Ctor(NaN);
385
- }
386
- Ctor.precision = pr + 6;
387
- Ctor.rounding = 1;
388
- x = x.div(new Ctor(1).minus(x.times(x)).sqrt().plus(1)).atan();
389
- Ctor.precision = pr;
390
- Ctor.rounding = rm;
391
- return x.times(2);
392
- };
393
- P.inverseTangent = P.atan = function() {
394
- var i, j, k, n, px, t, r, wpr, x2, x = this, Ctor = x.constructor, pr = Ctor.precision, rm = Ctor.rounding;
395
- if (!x.isFinite()) {
396
- if (!x.s)
397
- return new Ctor(NaN);
398
- if (pr + 4 <= PI_PRECISION) {
399
- r = getPi(Ctor, pr + 4, rm).times(0.5);
400
- r.s = x.s;
401
- return r;
402
- }
403
- } else if (x.isZero()) {
404
- return new Ctor(x);
405
- } else if (x.abs().eq(1) && pr + 4 <= PI_PRECISION) {
406
- r = getPi(Ctor, pr + 4, rm).times(0.25);
407
- r.s = x.s;
408
- return r;
409
- }
410
- Ctor.precision = wpr = pr + 10;
411
- Ctor.rounding = 1;
412
- k = Math.min(28, wpr / LOG_BASE + 2 | 0);
413
- for (i = k; i; --i)
414
- x = x.div(x.times(x).plus(1).sqrt().plus(1));
415
- external = false;
416
- j = Math.ceil(wpr / LOG_BASE);
417
- n = 1;
418
- x2 = x.times(x);
419
- r = new Ctor(x);
420
- px = x;
421
- for (; i !== -1; ) {
422
- px = px.times(x2);
423
- t = r.minus(px.div(n += 2));
424
- px = px.times(x2);
425
- r = t.plus(px.div(n += 2));
426
- if (r.d[j] !== void 0)
427
- for (i = j; r.d[i] === t.d[i] && i--; )
428
- ;
429
- }
430
- if (k)
431
- r = r.times(2 << k - 1);
432
- external = true;
433
- return finalise(r, Ctor.precision = pr, Ctor.rounding = rm, true);
434
- };
435
- P.isFinite = function() {
436
- return !!this.d;
437
- };
438
- P.isInteger = P.isInt = function() {
439
- return !!this.d && mathfloor(this.e / LOG_BASE) > this.d.length - 2;
440
- };
441
- P.isNaN = function() {
442
- return !this.s;
443
- };
444
- P.isNegative = P.isNeg = function() {
445
- return this.s < 0;
446
- };
447
- P.isPositive = P.isPos = function() {
448
- return this.s > 0;
449
- };
450
- P.isZero = function() {
451
- return !!this.d && this.d[0] === 0;
452
- };
453
- P.lessThan = P.lt = function(y) {
454
- return this.cmp(y) < 0;
455
- };
456
- P.lessThanOrEqualTo = P.lte = function(y) {
457
- return this.cmp(y) < 1;
458
- };
459
- P.logarithm = P.log = function(base) {
460
- var isBase10, d, denominator, k, inf, num, sd, r, arg = this, Ctor = arg.constructor, pr = Ctor.precision, rm = Ctor.rounding, guard = 5;
461
- if (base == null) {
462
- base = new Ctor(10);
463
- isBase10 = true;
111
+ numPart = s.substring(idx);
112
+ }
113
+ const dotIdx = numPart.indexOf(".");
114
+ let intPart;
115
+ let fracPart;
116
+ if (dotIdx !== -1) {
117
+ intPart = numPart.substring(0, dotIdx);
118
+ fracPart = numPart.substring(dotIdx + 1);
464
119
  } else {
465
- base = new Ctor(base);
466
- d = base.d;
467
- if (base.s < 0 || !d || !d[0] || base.eq(1))
468
- return new Ctor(NaN);
469
- isBase10 = base.eq(10);
120
+ intPart = numPart;
121
+ fracPart = "";
470
122
  }
471
- d = arg.d;
472
- if (arg.s < 0 || !d || !d[0] || arg.eq(1)) {
473
- return new Ctor(d && !d[0] ? -1 / 0 : arg.s != 1 ? NaN : d ? 0 : 1 / 0);
123
+ const combined = intPart + fracPart;
124
+ const exponent = sciExp - fracPart.length;
125
+ if (combined === "" || combined === "0" || /^0+$/.test(combined)) {
126
+ return {
127
+ mantissa: 0n,
128
+ exponent: 0,
129
+ special: SpecialValue.NONE,
130
+ negativeZero: negative
131
+ };
474
132
  }
475
- if (isBase10) {
476
- if (d.length > 1) {
477
- inf = true;
478
- } else {
479
- for (k = d[0]; k % 10 === 0; )
480
- k /= 10;
481
- inf = k !== 1;
133
+ let mantissa = BigInt(combined);
134
+ if (negative)
135
+ mantissa = -mantissa;
136
+ const [normMantissa, normExponent] = removeTrailingZeros(mantissa, exponent);
137
+ return {
138
+ mantissa: normMantissa,
139
+ exponent: normExponent,
140
+ special: SpecialValue.NONE,
141
+ negativeZero: false
142
+ };
143
+ }
144
+ var BigDecimal = class _BigDecimal {
145
+ constructor(value) {
146
+ __publicField(this, "_mantissa");
147
+ __publicField(this, "_exponent");
148
+ __publicField(this, "_special");
149
+ __publicField(this, "_negativeZero");
150
+ if (typeof value === "bigint") {
151
+ const [m, e] = removeTrailingZeros(value, 0);
152
+ this._mantissa = m;
153
+ this._exponent = e;
154
+ this._special = SpecialValue.NONE;
155
+ this._negativeZero = false;
156
+ return;
482
157
  }
483
- }
484
- external = false;
485
- sd = pr + guard;
486
- num = naturalLogarithm(arg, sd);
487
- denominator = isBase10 ? getLn10(Ctor, sd + 10) : naturalLogarithm(base, sd);
488
- r = divide(num, denominator, sd, 1);
489
- if (checkRoundingDigits(r.d, k = pr, rm)) {
490
- do {
491
- sd += 10;
492
- num = naturalLogarithm(arg, sd);
493
- denominator = isBase10 ? getLn10(Ctor, sd + 10) : naturalLogarithm(base, sd);
494
- r = divide(num, denominator, sd, 1);
495
- if (!inf) {
496
- if (+digitsToString(r.d).slice(k + 1, k + 15) + 1 == 1e14) {
497
- r = finalise(r, pr + 1, 0);
498
- }
499
- break;
158
+ if (typeof value === "number") {
159
+ if (Number.isNaN(value)) {
160
+ this._mantissa = 0n;
161
+ this._exponent = 0;
162
+ this._special = SpecialValue.NAN;
163
+ this._negativeZero = false;
164
+ return;
500
165
  }
501
- } while (checkRoundingDigits(r.d, k += 10, rm));
502
- }
503
- external = true;
504
- return finalise(r, pr, rm);
505
- };
506
- P.minus = P.sub = function(y) {
507
- var d, e, i, j, k, len, pr, rm, xd, xe, xLTy, yd, x = this, Ctor = x.constructor;
508
- y = new Ctor(y);
509
- if (!x.d || !y.d) {
510
- if (!x.s || !y.s)
511
- y = new Ctor(NaN);
512
- else if (x.d)
513
- y.s = -y.s;
514
- else
515
- y = new Ctor(y.d || x.s !== y.s ? x : NaN);
516
- return y;
517
- }
518
- if (x.s != y.s) {
519
- y.s = -y.s;
520
- return x.plus(y);
521
- }
522
- xd = x.d;
523
- yd = y.d;
524
- pr = Ctor.precision;
525
- rm = Ctor.rounding;
526
- if (!xd[0] || !yd[0]) {
527
- if (yd[0])
528
- y.s = -y.s;
529
- else if (xd[0])
530
- y = new Ctor(x);
531
- else
532
- return new Ctor(rm === 3 ? -0 : 0);
533
- return external ? finalise(y, pr, rm) : y;
534
- }
535
- e = mathfloor(y.e / LOG_BASE);
536
- xe = mathfloor(x.e / LOG_BASE);
537
- xd = xd.slice();
538
- k = xe - e;
539
- if (k) {
540
- xLTy = k < 0;
541
- if (xLTy) {
542
- d = xd;
543
- k = -k;
544
- len = yd.length;
545
- } else {
546
- d = yd;
547
- e = xe;
548
- len = xd.length;
549
- }
550
- i = Math.max(Math.ceil(pr / LOG_BASE), len) + 2;
551
- if (k > i) {
552
- k = i;
553
- d.length = 1;
554
- }
555
- d.reverse();
556
- for (i = k; i--; )
557
- d.push(0);
558
- d.reverse();
559
- } else {
560
- i = xd.length;
561
- len = yd.length;
562
- xLTy = i < len;
563
- if (xLTy)
564
- len = i;
565
- for (i = 0; i < len; i++) {
566
- if (xd[i] != yd[i]) {
567
- xLTy = xd[i] < yd[i];
568
- break;
166
+ if (value === Infinity) {
167
+ this._mantissa = 0n;
168
+ this._exponent = 0;
169
+ this._special = SpecialValue.POSITIVE_INFINITY;
170
+ this._negativeZero = false;
171
+ return;
569
172
  }
570
- }
571
- k = 0;
572
- }
573
- if (xLTy) {
574
- d = xd;
575
- xd = yd;
576
- yd = d;
577
- y.s = -y.s;
578
- }
579
- len = xd.length;
580
- for (i = yd.length - len; i > 0; --i)
581
- xd[len++] = 0;
582
- for (i = yd.length; i > k; ) {
583
- if (xd[--i] < yd[i]) {
584
- for (j = i; j && xd[--j] === 0; )
585
- xd[j] = BASE - 1;
586
- --xd[j];
587
- xd[i] += BASE;
588
- }
589
- xd[i] -= yd[i];
590
- }
591
- for (; xd[--len] === 0; )
592
- xd.pop();
593
- for (; xd[0] === 0; xd.shift())
594
- --e;
595
- if (!xd[0])
596
- return new Ctor(rm === 3 ? -0 : 0);
597
- y.d = xd;
598
- y.e = getBase10Exponent(xd, e);
599
- return external ? finalise(y, pr, rm) : y;
600
- };
601
- P.modulo = P.mod = function(y) {
602
- var q, x = this, Ctor = x.constructor;
603
- y = new Ctor(y);
604
- if (!x.d || !y.s || y.d && !y.d[0])
605
- return new Ctor(NaN);
606
- if (!y.d || x.d && !x.d[0]) {
607
- return finalise(new Ctor(x), Ctor.precision, Ctor.rounding);
608
- }
609
- external = false;
610
- if (Ctor.modulo == 9) {
611
- q = divide(x, y.abs(), 0, 3, 1);
612
- q.s *= y.s;
613
- } else {
614
- q = divide(x, y, 0, Ctor.modulo, 1);
615
- }
616
- q = q.times(y);
617
- external = true;
618
- return x.minus(q);
619
- };
620
- P.naturalExponential = P.exp = function() {
621
- return naturalExponential(this);
622
- };
623
- P.naturalLogarithm = P.ln = function() {
624
- return naturalLogarithm(this);
625
- };
626
- P.negated = P.neg = function() {
627
- var x = new this.constructor(this);
628
- x.s = -x.s;
629
- return finalise(x);
630
- };
631
- P.plus = P.add = function(y) {
632
- var carry, d, e, i, k, len, pr, rm, xd, yd, x = this, Ctor = x.constructor;
633
- y = new Ctor(y);
634
- if (!x.d || !y.d) {
635
- if (!x.s || !y.s)
636
- y = new Ctor(NaN);
637
- else if (!x.d)
638
- y = new Ctor(y.d || x.s === y.s ? x : NaN);
639
- return y;
640
- }
641
- if (x.s != y.s) {
642
- y.s = -y.s;
643
- return x.minus(y);
644
- }
645
- xd = x.d;
646
- yd = y.d;
647
- pr = Ctor.precision;
648
- rm = Ctor.rounding;
649
- if (!xd[0] || !yd[0]) {
650
- if (!yd[0])
651
- y = new Ctor(x);
652
- return external ? finalise(y, pr, rm) : y;
653
- }
654
- k = mathfloor(x.e / LOG_BASE);
655
- e = mathfloor(y.e / LOG_BASE);
656
- xd = xd.slice();
657
- i = k - e;
658
- if (i) {
659
- if (i < 0) {
660
- d = xd;
661
- i = -i;
662
- len = yd.length;
663
- } else {
664
- d = yd;
665
- e = k;
666
- len = xd.length;
667
- }
668
- k = Math.ceil(pr / LOG_BASE);
669
- len = k > len ? k + 1 : len + 1;
670
- if (i > len) {
671
- i = len;
672
- d.length = 1;
673
- }
674
- d.reverse();
675
- for (; i--; )
676
- d.push(0);
677
- d.reverse();
678
- }
679
- len = xd.length;
680
- i = yd.length;
681
- if (len - i < 0) {
682
- i = len;
683
- d = yd;
684
- yd = xd;
685
- xd = d;
686
- }
687
- for (carry = 0; i; ) {
688
- carry = (xd[--i] = xd[i] + yd[i] + carry) / BASE | 0;
689
- xd[i] %= BASE;
690
- }
691
- if (carry) {
692
- xd.unshift(carry);
693
- ++e;
694
- }
695
- for (len = xd.length; xd[--len] == 0; )
696
- xd.pop();
697
- y.d = xd;
698
- y.e = getBase10Exponent(xd, e);
699
- return external ? finalise(y, pr, rm) : y;
700
- };
701
- P.precision = P.sd = function(z) {
702
- var k, x = this;
703
- if (z !== void 0 && z !== !!z && z !== 1 && z !== 0)
704
- throw Error(invalidArgument + z);
705
- if (x.d) {
706
- k = getPrecision(x.d);
707
- if (z && x.e + 1 > k)
708
- k = x.e + 1;
709
- } else {
710
- k = NaN;
711
- }
712
- return k;
713
- };
714
- P.round = function() {
715
- var x = this, Ctor = x.constructor;
716
- return finalise(new Ctor(x), x.e + 1, Ctor.rounding);
717
- };
718
- P.sine = P.sin = function() {
719
- var pr, rm, x = this, Ctor = x.constructor;
720
- if (!x.isFinite())
721
- return new Ctor(NaN);
722
- if (x.isZero())
723
- return new Ctor(x);
724
- pr = Ctor.precision;
725
- rm = Ctor.rounding;
726
- Ctor.precision = pr + Math.max(x.e, x.sd()) + LOG_BASE;
727
- Ctor.rounding = 1;
728
- x = sine(Ctor, toLessThanHalfPi(Ctor, x));
729
- Ctor.precision = pr;
730
- Ctor.rounding = rm;
731
- return finalise(quadrant > 2 ? x.neg() : x, pr, rm, true);
732
- };
733
- P.squareRoot = P.sqrt = function() {
734
- var m, n, sd, r, rep, t, x = this, d = x.d, e = x.e, s = x.s, Ctor = x.constructor;
735
- if (s !== 1 || !d || !d[0]) {
736
- return new Ctor(!s || s < 0 && (!d || d[0]) ? NaN : d ? x : 1 / 0);
737
- }
738
- external = false;
739
- s = Math.sqrt(+x);
740
- if (s == 0 || s == 1 / 0) {
741
- n = digitsToString(d);
742
- if ((n.length + e) % 2 == 0)
743
- n += "0";
744
- s = Math.sqrt(n);
745
- e = mathfloor((e + 1) / 2) - (e < 0 || e % 2);
746
- if (s == 1 / 0) {
747
- n = "5e" + e;
748
- } else {
749
- n = s.toExponential();
750
- n = n.slice(0, n.indexOf("e") + 1) + e;
751
- }
752
- r = new Ctor(n);
753
- } else {
754
- r = new Ctor(s.toString());
755
- }
756
- sd = (e = Ctor.precision) + 3;
757
- for (; ; ) {
758
- t = r;
759
- r = t.plus(divide(x, t, sd + 2, 1)).times(0.5);
760
- if (digitsToString(t.d).slice(0, sd) === (n = digitsToString(r.d)).slice(0, sd)) {
761
- n = n.slice(sd - 3, sd + 1);
762
- if (n == "9999" || !rep && n == "4999") {
763
- if (!rep) {
764
- finalise(t, e + 1, 0);
765
- if (t.times(t).eq(x)) {
766
- r = t;
767
- break;
768
- }
769
- }
770
- sd += 4;
771
- rep = 1;
772
- } else {
773
- if (!+n || !+n.slice(1) && n.charAt(0) == "5") {
774
- finalise(r, e + 1, 1);
775
- m = !r.times(r).eq(x);
776
- }
777
- break;
173
+ if (value === -Infinity) {
174
+ this._mantissa = 0n;
175
+ this._exponent = 0;
176
+ this._special = SpecialValue.NEGATIVE_INFINITY;
177
+ this._negativeZero = false;
178
+ return;
778
179
  }
180
+ if (value === 0) {
181
+ this._mantissa = 0n;
182
+ this._exponent = 0;
183
+ this._special = SpecialValue.NONE;
184
+ this._negativeZero = Object.is(value, -0);
185
+ return;
186
+ }
187
+ value = String(value);
779
188
  }
780
- }
781
- external = true;
782
- return finalise(r, e, Ctor.rounding, m);
783
- };
784
- P.tangent = P.tan = function() {
785
- var pr, rm, x = this, Ctor = x.constructor;
786
- if (!x.isFinite())
787
- return new Ctor(NaN);
788
- if (x.isZero())
789
- return new Ctor(x);
790
- pr = Ctor.precision;
791
- rm = Ctor.rounding;
792
- Ctor.precision = pr + 10;
793
- Ctor.rounding = 1;
794
- x = x.sin();
795
- x.s = 1;
796
- x = divide(x, new Ctor(1).minus(x.times(x)).sqrt(), pr + 10, 0);
797
- Ctor.precision = pr;
798
- Ctor.rounding = rm;
799
- return finalise(quadrant == 2 || quadrant == 4 ? x.neg() : x, pr, rm, true);
800
- };
801
- P.times = P.mul = function(y) {
802
- var carry, e, i, k, r, rL, t, xdL, ydL, x = this, Ctor = x.constructor, xd = x.d, yd = (y = new Ctor(y)).d;
803
- y.s *= x.s;
804
- if (!xd || !xd[0] || !yd || !yd[0]) {
805
- return new Ctor(!y.s || xd && !xd[0] && !yd || yd && !yd[0] && !xd ? NaN : !xd || !yd ? y.s / 0 : y.s * 0);
806
- }
807
- e = mathfloor(x.e / LOG_BASE) + mathfloor(y.e / LOG_BASE);
808
- xdL = xd.length;
809
- ydL = yd.length;
810
- if (xdL < ydL) {
811
- r = xd;
812
- xd = yd;
813
- yd = r;
814
- rL = xdL;
815
- xdL = ydL;
816
- ydL = rL;
817
- }
818
- r = [];
819
- rL = xdL + ydL;
820
- for (i = rL; i--; )
821
- r.push(0);
822
- for (i = ydL; --i >= 0; ) {
823
- carry = 0;
824
- for (k = xdL + i; k > i; ) {
825
- t = r[k] + yd[i] * xd[k - i - 1] + carry;
826
- r[k--] = t % BASE | 0;
827
- carry = t / BASE | 0;
828
- }
829
- r[k] = (r[k] + carry) % BASE | 0;
830
- }
831
- for (; !r[--rL]; )
832
- r.pop();
833
- if (carry)
834
- ++e;
835
- else
836
- r.shift();
837
- y.d = r;
838
- y.e = getBase10Exponent(r, e);
839
- return external ? finalise(y, Ctor.precision, Ctor.rounding) : y;
840
- };
841
- P.toBinary = function(sd, rm) {
842
- return toStringBinary(this, 2, sd, rm);
843
- };
844
- P.toDecimalPlaces = P.toDP = function(dp, rm) {
845
- var x = this, Ctor = x.constructor;
846
- x = new Ctor(x);
847
- if (dp === void 0)
848
- return x;
849
- checkInt32(dp, 0, MAX_DIGITS);
850
- if (rm === void 0)
851
- rm = Ctor.rounding;
852
- else
853
- checkInt32(rm, 0, 8);
854
- return finalise(x, dp + x.e + 1, rm);
855
- };
856
- P.toExponential = function(dp, rm) {
857
- var str, x = this, Ctor = x.constructor;
858
- if (dp === void 0) {
859
- str = finiteToString(x, true);
860
- } else {
861
- checkInt32(dp, 0, MAX_DIGITS);
862
- if (rm === void 0)
863
- rm = Ctor.rounding;
864
- else
865
- checkInt32(rm, 0, 8);
866
- x = finalise(new Ctor(x), dp + 1, rm);
867
- str = finiteToString(x, true, dp + 1);
868
- }
869
- return x.isNeg() && !x.isZero() ? "-" + str : str;
870
- };
871
- P.toFixed = function(dp, rm) {
872
- var str, y, x = this, Ctor = x.constructor;
873
- if (dp === void 0) {
874
- str = finiteToString(x);
875
- } else {
876
- checkInt32(dp, 0, MAX_DIGITS);
877
- if (rm === void 0)
878
- rm = Ctor.rounding;
879
- else
880
- checkInt32(rm, 0, 8);
881
- y = finalise(new Ctor(x), dp + x.e + 1, rm);
882
- str = finiteToString(y, false, dp + y.e + 1);
883
- }
884
- return x.isNeg() && !x.isZero() ? "-" + str : str;
885
- };
886
- P.toFraction = function(maxD) {
887
- var d, d0, d1, d2, e, k, n, n0, n1, pr, q, r, x = this, xd = x.d, Ctor = x.constructor;
888
- if (!xd)
889
- return new Ctor(x);
890
- n1 = d0 = new Ctor(1);
891
- d1 = n0 = new Ctor(0);
892
- d = new Ctor(d1);
893
- e = d.e = getPrecision(xd) - x.e - 1;
894
- k = e % LOG_BASE;
895
- d.d[0] = mathpow(10, k < 0 ? LOG_BASE + k : k);
896
- if (maxD == null) {
897
- maxD = e > 0 ? d : n1;
898
- } else {
899
- n = new Ctor(maxD);
900
- if (!n.isInt() || n.lt(n1))
901
- throw Error(invalidArgument + n);
902
- maxD = n.gt(d) ? e > 0 ? d : n1 : n;
903
- }
904
- external = false;
905
- n = new Ctor(digitsToString(xd));
906
- pr = Ctor.precision;
907
- Ctor.precision = e = xd.length * LOG_BASE * 2;
908
- for (; ; ) {
909
- q = divide(n, d, 0, 1, 1);
910
- d2 = d0.plus(q.times(d1));
911
- if (d2.cmp(maxD) == 1)
912
- break;
913
- d0 = d1;
914
- d1 = d2;
915
- d2 = n1;
916
- n1 = n0.plus(q.times(d2));
917
- n0 = d2;
918
- d2 = d;
919
- d = n.minus(q.times(d2));
920
- n = d2;
921
- }
922
- d2 = divide(maxD.minus(d0), d1, 0, 1, 1);
923
- n0 = n0.plus(d2.times(n1));
924
- d0 = d0.plus(d2.times(d1));
925
- n0.s = n1.s = x.s;
926
- r = divide(n1, d1, e, 1).minus(x).abs().cmp(divide(n0, d0, e, 1).minus(x).abs()) < 1 ? [n1, d1] : [n0, d0];
927
- Ctor.precision = pr;
928
- external = true;
929
- return r;
930
- };
931
- P.toHexadecimal = P.toHex = function(sd, rm) {
932
- return toStringBinary(this, 16, sd, rm);
933
- };
934
- P.toNearest = function(y, rm) {
935
- var x = this, Ctor = x.constructor;
936
- x = new Ctor(x);
937
- if (y == null) {
938
- if (!x.d)
939
- return x;
940
- y = new Ctor(1);
941
- rm = Ctor.rounding;
942
- } else {
943
- y = new Ctor(y);
944
- if (rm === void 0) {
945
- rm = Ctor.rounding;
946
- } else {
947
- checkInt32(rm, 0, 8);
189
+ const parsed = parseDecimalString(value);
190
+ this._mantissa = parsed.mantissa;
191
+ this._exponent = parsed.exponent;
192
+ this._special = parsed.special;
193
+ this._negativeZero = parsed.negativeZero;
194
+ }
195
+ // Private constructor for internal use
196
+ static _create(mantissa, exponent, special, negativeZero) {
197
+ const bd = Object.create(_BigDecimal.prototype);
198
+ bd._mantissa = mantissa;
199
+ bd._exponent = exponent;
200
+ bd._special = special;
201
+ bd._negativeZero = negativeZero;
202
+ return bd;
203
+ }
204
+ // Auto-coerce to BigDecimal for decimal.js compat
205
+ static _coerce(v) {
206
+ return v instanceof _BigDecimal ? v : new _BigDecimal(v);
207
+ }
208
+ // --- Arithmetic ---
209
+ times(y) {
210
+ const other = _BigDecimal._coerce(y);
211
+ if (this._special || other._special) {
212
+ return this._specialArith(other, "times");
948
213
  }
949
- if (!x.d)
950
- return y.s ? x : y;
951
- if (!y.d) {
952
- if (y.s)
953
- y.s = x.s;
954
- return y;
214
+ if (this._mantissa === 0n || other._mantissa === 0n) {
215
+ const negZero = this._isSignNegative() ? !other._isSignNegative() : other._isSignNegative();
216
+ return _BigDecimal._create(0n, 0, SpecialValue.NONE, negZero);
955
217
  }
956
- }
957
- if (y.d[0]) {
958
- external = false;
959
- x = divide(x, y, 0, rm, 1).times(y);
960
- external = true;
961
- finalise(x);
962
- } else {
963
- y.s = x.s;
964
- x = y;
965
- }
966
- return x;
967
- };
968
- P.toNumber = function() {
969
- return +this;
970
- };
971
- P.toOctal = function(sd, rm) {
972
- return toStringBinary(this, 8, sd, rm);
973
- };
974
- P.toPower = P.pow = function(y) {
975
- var e, k, pr, r, rm, s, x = this, Ctor = x.constructor, yn = +(y = new Ctor(y));
976
- if (!x.d || !y.d || !x.d[0] || !y.d[0])
977
- return new Ctor(mathpow(+x, yn));
978
- x = new Ctor(x);
979
- if (x.eq(1))
980
- return x;
981
- pr = Ctor.precision;
982
- rm = Ctor.rounding;
983
- if (y.eq(1))
984
- return finalise(x, pr, rm);
985
- e = mathfloor(y.e / LOG_BASE);
986
- if (e >= y.d.length - 1 && (k = yn < 0 ? -yn : yn) <= MAX_SAFE_INTEGER) {
987
- r = intPow(Ctor, x, k, pr);
988
- return y.s < 0 ? new Ctor(1).div(r) : finalise(r, pr, rm);
989
- }
990
- s = x.s;
991
- if (s < 0) {
992
- if (e < y.d.length - 1)
993
- return new Ctor(NaN);
994
- if ((y.d[e] & 1) == 0)
995
- s = 1;
996
- if (x.e == 0 && x.d[0] == 1 && x.d.length == 1) {
997
- x.s = s;
998
- return x;
218
+ const m = this._mantissa * other._mantissa;
219
+ const e = this._exponent + other._exponent;
220
+ const [nm, ne] = removeTrailingZeros(m, e);
221
+ return _BigDecimal._create(nm, ne, SpecialValue.NONE, false);
222
+ }
223
+ div(y) {
224
+ const other = _BigDecimal._coerce(y);
225
+ if (this._special || other._special) {
226
+ return this._specialArith(other, "div");
999
227
  }
1000
- }
1001
- k = mathpow(+x, yn);
1002
- e = k == 0 || !isFinite(k) ? mathfloor(yn * (Math.log("0." + digitsToString(x.d)) / Math.LN10 + x.e + 1)) : new Ctor(k + "").e;
1003
- if (e > Ctor.maxE + 1 || e < Ctor.minE - 1)
1004
- return new Ctor(e > 0 ? s / 0 : 0);
1005
- external = false;
1006
- Ctor.rounding = x.s = 1;
1007
- k = Math.min(12, (e + "").length);
1008
- r = naturalExponential(y.times(naturalLogarithm(x, pr + k)), pr);
1009
- if (r.d) {
1010
- r = finalise(r, pr + 5, 1);
1011
- if (checkRoundingDigits(r.d, pr, rm)) {
1012
- e = pr + 10;
1013
- r = finalise(naturalExponential(y.times(naturalLogarithm(x, e + k)), e), e + 5, 1);
1014
- if (+digitsToString(r.d).slice(pr + 1, pr + 15) + 1 == 1e14) {
1015
- r = finalise(r, pr + 1, 0);
228
+ if (other._mantissa === 0n) {
229
+ if (this._mantissa === 0n) {
230
+ return _BigDecimal._create(0n, 0, SpecialValue.NAN, false);
1016
231
  }
232
+ const neg = this._isSignNegative() !== other._isSignNegative();
233
+ return _BigDecimal._create(0n, 0, neg ? SpecialValue.NEGATIVE_INFINITY : SpecialValue.POSITIVE_INFINITY, false);
1017
234
  }
1018
- }
1019
- r.s = s;
1020
- external = true;
1021
- Ctor.rounding = rm;
1022
- return finalise(r, pr, rm);
1023
- };
1024
- P.toPrecision = function(sd, rm) {
1025
- var str, x = this, Ctor = x.constructor;
1026
- if (sd === void 0) {
1027
- str = finiteToString(x, x.e <= Ctor.toExpNeg || x.e >= Ctor.toExpPos);
1028
- } else {
1029
- checkInt32(sd, 1, MAX_DIGITS);
1030
- if (rm === void 0)
1031
- rm = Ctor.rounding;
1032
- else
1033
- checkInt32(rm, 0, 8);
1034
- x = finalise(new Ctor(x), sd, rm);
1035
- str = finiteToString(x, sd <= x.e || x.e <= Ctor.toExpNeg, sd);
1036
- }
1037
- return x.isNeg() && !x.isZero() ? "-" + str : str;
1038
- };
1039
- P.toSignificantDigits = P.toSD = function(sd, rm) {
1040
- var x = this, Ctor = x.constructor;
1041
- if (sd === void 0) {
1042
- sd = Ctor.precision;
1043
- rm = Ctor.rounding;
1044
- } else {
1045
- checkInt32(sd, 1, MAX_DIGITS);
1046
- if (rm === void 0)
1047
- rm = Ctor.rounding;
1048
- else
1049
- checkInt32(rm, 0, 8);
1050
- }
1051
- return finalise(new Ctor(x), sd, rm);
1052
- };
1053
- P.toString = function() {
1054
- var x = this, Ctor = x.constructor, str = finiteToString(x, x.e <= Ctor.toExpNeg || x.e >= Ctor.toExpPos);
1055
- return x.isNeg() && !x.isZero() ? "-" + str : str;
1056
- };
1057
- P.truncated = P.trunc = function() {
1058
- return finalise(new this.constructor(this), this.e + 1, 1);
1059
- };
1060
- P.valueOf = P.toJSON = function() {
1061
- var x = this, Ctor = x.constructor, str = finiteToString(x, x.e <= Ctor.toExpNeg || x.e >= Ctor.toExpPos);
1062
- return x.isNeg() ? "-" + str : str;
1063
- };
1064
- function digitsToString(d) {
1065
- var i, k, ws, indexOfLastWord = d.length - 1, str = "", w = d[0];
1066
- if (indexOfLastWord > 0) {
1067
- str += w;
1068
- for (i = 1; i < indexOfLastWord; i++) {
1069
- ws = d[i] + "";
1070
- k = LOG_BASE - ws.length;
1071
- if (k)
1072
- str += getZeroString(k);
1073
- str += ws;
235
+ if (this._mantissa === 0n) {
236
+ const negZero = this._isSignNegative() !== other._isSignNegative();
237
+ return _BigDecimal._create(0n, 0, SpecialValue.NONE, negZero);
1074
238
  }
1075
- w = d[i];
1076
- ws = w + "";
1077
- k = LOG_BASE - ws.length;
1078
- if (k)
1079
- str += getZeroString(k);
1080
- } else if (w === 0) {
1081
- return "0";
1082
- }
1083
- for (; w % 10 === 0; )
1084
- w /= 10;
1085
- return str + w;
1086
- }
1087
- function checkInt32(i, min2, max2) {
1088
- if (i !== ~~i || i < min2 || i > max2) {
1089
- throw Error(invalidArgument + i);
1090
- }
1091
- }
1092
- function checkRoundingDigits(d, i, rm, repeating) {
1093
- var di, k, r, rd;
1094
- for (k = d[0]; k >= 10; k /= 10)
1095
- --i;
1096
- if (--i < 0) {
1097
- i += LOG_BASE;
1098
- di = 0;
1099
- } else {
1100
- di = Math.ceil((i + 1) / LOG_BASE);
1101
- i %= LOG_BASE;
1102
- }
1103
- k = mathpow(10, LOG_BASE - i);
1104
- rd = d[di] % k | 0;
1105
- if (repeating == null) {
1106
- if (i < 3) {
1107
- if (i == 0)
1108
- rd = rd / 100 | 0;
1109
- else if (i == 1)
1110
- rd = rd / 10 | 0;
1111
- r = rm < 4 && rd == 99999 || rm > 3 && rd == 49999 || rd == 5e4 || rd == 0;
1112
- } else {
1113
- r = (rm < 4 && rd + 1 == k || rm > 3 && rd + 1 == k / 2) && (d[di + 1] / k / 100 | 0) == mathpow(10, i - 2) - 1 || (rd == k / 2 || rd == 0) && (d[di + 1] / k / 100 | 0) == 0;
239
+ const scaledNumerator = this._mantissa * bigintPow10(DIV_PRECISION);
240
+ const quotient = scaledNumerator / other._mantissa;
241
+ const newExponent = this._exponent - other._exponent - DIV_PRECISION;
242
+ const [nm, ne] = removeTrailingZeros(quotient, newExponent);
243
+ return _BigDecimal._create(nm, ne, SpecialValue.NONE, false);
244
+ }
245
+ plus(y) {
246
+ const other = _BigDecimal._coerce(y);
247
+ if (this._special || other._special) {
248
+ return this._specialArith(other, "plus");
1114
249
  }
1115
- } else {
1116
- if (i < 4) {
1117
- if (i == 0)
1118
- rd = rd / 1e3 | 0;
1119
- else if (i == 1)
1120
- rd = rd / 100 | 0;
1121
- else if (i == 2)
1122
- rd = rd / 10 | 0;
1123
- r = (repeating || rm < 4) && rd == 9999 || !repeating && rm > 3 && rd == 4999;
1124
- } else {
1125
- r = ((repeating || rm < 4) && rd + 1 == k || !repeating && rm > 3 && rd + 1 == k / 2) && (d[di + 1] / k / 1e3 | 0) == mathpow(10, i - 3) - 1;
250
+ if (this._mantissa === 0n && other._mantissa === 0n) {
251
+ const negZero = this._negativeZero && other._negativeZero;
252
+ return _BigDecimal._create(0n, 0, SpecialValue.NONE, negZero);
1126
253
  }
1127
- }
1128
- return r;
1129
- }
1130
- function convertBase(str, baseIn, baseOut) {
1131
- var j, arr = [0], arrL, i = 0, strL = str.length;
1132
- for (; i < strL; ) {
1133
- for (arrL = arr.length; arrL--; )
1134
- arr[arrL] *= baseIn;
1135
- arr[0] += NUMERALS.indexOf(str.charAt(i++));
1136
- for (j = 0; j < arr.length; j++) {
1137
- if (arr[j] > baseOut - 1) {
1138
- if (arr[j + 1] === void 0)
1139
- arr[j + 1] = 0;
1140
- arr[j + 1] += arr[j] / baseOut | 0;
1141
- arr[j] %= baseOut;
1142
- }
254
+ if (this._mantissa === 0n)
255
+ return other;
256
+ if (other._mantissa === 0n)
257
+ return this;
258
+ let m1 = this._mantissa;
259
+ let m2 = other._mantissa;
260
+ const e1 = this._exponent;
261
+ const e2 = other._exponent;
262
+ const minE = Math.min(e1, e2);
263
+ if (e1 > minE)
264
+ m1 *= bigintPow10(e1 - minE);
265
+ if (e2 > minE)
266
+ m2 *= bigintPow10(e2 - minE);
267
+ const sum = m1 + m2;
268
+ if (sum === 0n) {
269
+ return _BigDecimal._create(0n, 0, SpecialValue.NONE, false);
1143
270
  }
271
+ const [nm, ne] = removeTrailingZeros(sum, minE);
272
+ return _BigDecimal._create(nm, ne, SpecialValue.NONE, false);
1144
273
  }
1145
- return arr.reverse();
1146
- }
1147
- function cosine(Ctor, x) {
1148
- var k, len, y;
1149
- if (x.isZero())
1150
- return x;
1151
- len = x.d.length;
1152
- if (len < 32) {
1153
- k = Math.ceil(len / 3);
1154
- y = (1 / tinyPow(4, k)).toString();
1155
- } else {
1156
- k = 16;
1157
- y = "2.3283064365386962890625e-10";
1158
- }
1159
- Ctor.precision += k;
1160
- x = taylorSeries(Ctor, 1, x.times(y), new Ctor(1));
1161
- for (var i = k; i--; ) {
1162
- var cos2x = x.times(x);
1163
- x = cos2x.times(cos2x).minus(cos2x).times(8).plus(1);
1164
- }
1165
- Ctor.precision -= k;
1166
- return x;
1167
- }
1168
- var divide = /* @__PURE__ */ function() {
1169
- function multiplyInteger(x, k, base) {
1170
- var temp, carry = 0, i = x.length;
1171
- for (x = x.slice(); i--; ) {
1172
- temp = x[i] * k + carry;
1173
- x[i] = temp % base | 0;
1174
- carry = temp / base | 0;
1175
- }
1176
- if (carry)
1177
- x.unshift(carry);
1178
- return x;
274
+ minus(y) {
275
+ return this.plus(_BigDecimal._coerce(y).negated());
1179
276
  }
1180
- function compare(a, b, aL, bL) {
1181
- var i, r;
1182
- if (aL != bL) {
1183
- r = aL > bL ? 1 : -1;
1184
- } else {
1185
- for (i = r = 0; i < aL; i++) {
1186
- if (a[i] != b[i]) {
1187
- r = a[i] > b[i] ? 1 : -1;
1188
- break;
1189
- }
277
+ mod(y) {
278
+ const other = _BigDecimal._coerce(y);
279
+ if (this._special || other._special) {
280
+ if (this._special === SpecialValue.NAN || other._special === SpecialValue.NAN) {
281
+ return _BigDecimal._create(0n, 0, SpecialValue.NAN, false);
282
+ }
283
+ if (this._special === SpecialValue.POSITIVE_INFINITY || this._special === SpecialValue.NEGATIVE_INFINITY) {
284
+ return _BigDecimal._create(0n, 0, SpecialValue.NAN, false);
285
+ }
286
+ if (other._special === SpecialValue.POSITIVE_INFINITY || other._special === SpecialValue.NEGATIVE_INFINITY) {
287
+ return this;
1190
288
  }
1191
289
  }
1192
- return r;
1193
- }
1194
- function subtract(a, b, aL, base) {
1195
- var i = 0;
1196
- for (; aL--; ) {
1197
- a[aL] -= i;
1198
- i = a[aL] < b[aL] ? 1 : 0;
1199
- a[aL] = i * base + a[aL] - b[aL];
290
+ if (other._mantissa === 0n) {
291
+ return _BigDecimal._create(0n, 0, SpecialValue.NAN, false);
1200
292
  }
1201
- for (; !a[0] && a.length > 1; )
1202
- a.shift();
1203
- }
1204
- return function(x, y, pr, rm, dp, base) {
1205
- var cmp, e, i, k, logBase, more, prod, prodL, q, qd, rem, remL, rem0, sd, t, xi, xL, yd0, yL, yz, Ctor = x.constructor, sign2 = x.s == y.s ? 1 : -1, xd = x.d, yd = y.d;
1206
- if (!xd || !xd[0] || !yd || !yd[0]) {
1207
- return new Ctor(
1208
- // Return NaN if either NaN, or both Infinity or 0.
1209
- !x.s || !y.s || (xd ? yd && xd[0] == yd[0] : !yd) ? NaN : (
1210
- // Return ±0 if x is 0 or y is ±Infinity, or return ±Infinity as y is 0.
1211
- xd && xd[0] == 0 || !yd ? sign2 * 0 : sign2 / 0
1212
- )
1213
- );
293
+ if (this._mantissa === 0n) {
294
+ return this;
1214
295
  }
1215
- if (base) {
1216
- logBase = 1;
1217
- e = x.e - y.e;
1218
- } else {
1219
- base = BASE;
1220
- logBase = LOG_BASE;
1221
- e = mathfloor(x.e / logBase) - mathfloor(y.e / logBase);
296
+ let m1 = this._mantissa;
297
+ let m2 = other._mantissa;
298
+ const e1 = this._exponent;
299
+ const e2 = other._exponent;
300
+ const minE = Math.min(e1, e2);
301
+ if (e1 > minE)
302
+ m1 *= bigintPow10(e1 - minE);
303
+ if (e2 > minE)
304
+ m2 *= bigintPow10(e2 - minE);
305
+ const remainder = m1 % m2;
306
+ if (remainder === 0n) {
307
+ return _BigDecimal._create(0n, 0, SpecialValue.NONE, false);
1222
308
  }
1223
- yL = yd.length;
1224
- xL = xd.length;
1225
- q = new Ctor(sign2);
1226
- qd = q.d = [];
1227
- for (i = 0; yd[i] == (xd[i] || 0); i++)
1228
- ;
1229
- if (yd[i] > (xd[i] || 0))
1230
- e--;
1231
- if (pr == null) {
1232
- sd = pr = Ctor.precision;
1233
- rm = Ctor.rounding;
1234
- } else if (dp) {
1235
- sd = pr + (x.e - y.e) + 1;
1236
- } else {
1237
- sd = pr;
309
+ const [nm, ne] = removeTrailingZeros(remainder, minE);
310
+ return _BigDecimal._create(nm, ne, SpecialValue.NONE, false);
311
+ }
312
+ abs() {
313
+ if (this._special === SpecialValue.NAN)
314
+ return this;
315
+ if (this._special === SpecialValue.NEGATIVE_INFINITY) {
316
+ return _BigDecimal._create(0n, 0, SpecialValue.POSITIVE_INFINITY, false);
1238
317
  }
1239
- if (sd < 0) {
1240
- qd.push(1);
1241
- more = true;
1242
- } else {
1243
- sd = sd / logBase + 2 | 0;
1244
- i = 0;
1245
- if (yL == 1) {
1246
- k = 0;
1247
- yd = yd[0];
1248
- sd++;
1249
- for (; (i < xL || k) && sd--; i++) {
1250
- t = k * base + (xd[i] || 0);
1251
- qd[i] = t / yd | 0;
1252
- k = t % yd | 0;
1253
- }
1254
- more = k || i < xL;
1255
- } else {
1256
- k = base / (yd[0] + 1) | 0;
1257
- if (k > 1) {
1258
- yd = multiplyInteger(yd, k, base);
1259
- xd = multiplyInteger(xd, k, base);
1260
- yL = yd.length;
1261
- xL = xd.length;
1262
- }
1263
- xi = yL;
1264
- rem = xd.slice(0, yL);
1265
- remL = rem.length;
1266
- for (; remL < yL; )
1267
- rem[remL++] = 0;
1268
- yz = yd.slice();
1269
- yz.unshift(0);
1270
- yd0 = yd[0];
1271
- if (yd[1] >= base / 2)
1272
- ++yd0;
1273
- do {
1274
- k = 0;
1275
- cmp = compare(yd, rem, yL, remL);
1276
- if (cmp < 0) {
1277
- rem0 = rem[0];
1278
- if (yL != remL)
1279
- rem0 = rem0 * base + (rem[1] || 0);
1280
- k = rem0 / yd0 | 0;
1281
- if (k > 1) {
1282
- if (k >= base)
1283
- k = base - 1;
1284
- prod = multiplyInteger(yd, k, base);
1285
- prodL = prod.length;
1286
- remL = rem.length;
1287
- cmp = compare(prod, rem, prodL, remL);
1288
- if (cmp == 1) {
1289
- k--;
1290
- subtract(prod, yL < prodL ? yz : yd, prodL, base);
1291
- }
1292
- } else {
1293
- if (k == 0)
1294
- cmp = k = 1;
1295
- prod = yd.slice();
1296
- }
1297
- prodL = prod.length;
1298
- if (prodL < remL)
1299
- prod.unshift(0);
1300
- subtract(rem, prod, remL, base);
1301
- if (cmp == -1) {
1302
- remL = rem.length;
1303
- cmp = compare(yd, rem, yL, remL);
1304
- if (cmp < 1) {
1305
- k++;
1306
- subtract(rem, yL < remL ? yz : yd, remL, base);
1307
- }
1308
- }
1309
- remL = rem.length;
1310
- } else if (cmp === 0) {
1311
- k++;
1312
- rem = [0];
1313
- }
1314
- qd[i++] = k;
1315
- if (cmp && rem[0]) {
1316
- rem[remL++] = xd[xi] || 0;
1317
- } else {
1318
- rem = [xd[xi]];
1319
- remL = 1;
1320
- }
1321
- } while ((xi++ < xL || rem[0] !== void 0) && sd--);
1322
- more = rem[0] !== void 0;
1323
- }
1324
- if (!qd[0])
1325
- qd.shift();
318
+ return _BigDecimal._create(bigintAbs(this._mantissa), this._exponent, this._special, false);
319
+ }
320
+ negated() {
321
+ if (this._special === SpecialValue.NAN)
322
+ return this;
323
+ if (this._special === SpecialValue.POSITIVE_INFINITY) {
324
+ return _BigDecimal._create(0n, 0, SpecialValue.NEGATIVE_INFINITY, false);
1326
325
  }
1327
- if (logBase == 1) {
1328
- q.e = e;
1329
- inexact = more;
1330
- } else {
1331
- for (i = 1, k = qd[0]; k >= 10; k /= 10)
1332
- i++;
1333
- q.e = i + e * logBase - 1;
1334
- finalise(q, dp ? pr + q.e + 1 : pr, rm, more);
326
+ if (this._special === SpecialValue.NEGATIVE_INFINITY) {
327
+ return _BigDecimal._create(0n, 0, SpecialValue.POSITIVE_INFINITY, false);
1335
328
  }
1336
- return q;
1337
- };
1338
- }();
1339
- function finalise(x, sd, rm, isTruncated) {
1340
- var digits, i, j, k, rd, roundUp, w, xd, xdi, Ctor = x.constructor;
1341
- out:
1342
- if (sd != null) {
1343
- xd = x.d;
1344
- if (!xd)
1345
- return x;
1346
- for (digits = 1, k = xd[0]; k >= 10; k /= 10)
1347
- digits++;
1348
- i = sd - digits;
1349
- if (i < 0) {
1350
- i += LOG_BASE;
1351
- j = sd;
1352
- w = xd[xdi = 0];
1353
- rd = w / mathpow(10, digits - j - 1) % 10 | 0;
1354
- } else {
1355
- xdi = Math.ceil((i + 1) / LOG_BASE);
1356
- k = xd.length;
1357
- if (xdi >= k) {
1358
- if (isTruncated) {
1359
- for (; k++ <= xdi; )
1360
- xd.push(0);
1361
- w = rd = 0;
1362
- digits = 1;
1363
- i %= LOG_BASE;
1364
- j = i - LOG_BASE + 1;
1365
- } else {
1366
- break out;
1367
- }
1368
- } else {
1369
- w = k = xd[xdi];
1370
- for (digits = 1; k >= 10; k /= 10)
1371
- digits++;
1372
- i %= LOG_BASE;
1373
- j = i - LOG_BASE + digits;
1374
- rd = j < 0 ? 0 : w / mathpow(10, digits - j - 1) % 10 | 0;
1375
- }
1376
- }
1377
- isTruncated = isTruncated || sd < 0 || xd[xdi + 1] !== void 0 || (j < 0 ? w : w % mathpow(10, digits - j - 1));
1378
- roundUp = rm < 4 ? (rd || isTruncated) && (rm == 0 || rm == (x.s < 0 ? 3 : 2)) : rd > 5 || rd == 5 && (rm == 4 || isTruncated || rm == 6 && // Check whether the digit to the left of the rounding digit is odd.
1379
- (i > 0 ? j > 0 ? w / mathpow(10, digits - j) : 0 : xd[xdi - 1]) % 10 & 1 || rm == (x.s < 0 ? 8 : 7));
1380
- if (sd < 1 || !xd[0]) {
1381
- xd.length = 0;
1382
- if (roundUp) {
1383
- sd -= x.e + 1;
1384
- xd[0] = mathpow(10, (LOG_BASE - sd % LOG_BASE) % LOG_BASE);
1385
- x.e = -sd || 0;
1386
- } else {
1387
- xd[0] = x.e = 0;
1388
- }
1389
- return x;
1390
- }
1391
- if (i == 0) {
1392
- xd.length = xdi;
1393
- k = 1;
1394
- xdi--;
1395
- } else {
1396
- xd.length = xdi + 1;
1397
- k = mathpow(10, LOG_BASE - i);
1398
- xd[xdi] = j > 0 ? (w / mathpow(10, digits - j) % mathpow(10, j) | 0) * k : 0;
1399
- }
1400
- if (roundUp) {
1401
- for (; ; ) {
1402
- if (xdi == 0) {
1403
- for (i = 1, j = xd[0]; j >= 10; j /= 10)
1404
- i++;
1405
- j = xd[0] += k;
1406
- for (k = 1; j >= 10; j /= 10)
1407
- k++;
1408
- if (i != k) {
1409
- x.e++;
1410
- if (xd[0] == BASE)
1411
- xd[0] = 1;
1412
- }
1413
- break;
1414
- } else {
1415
- xd[xdi] += k;
1416
- if (xd[xdi] != BASE)
1417
- break;
1418
- xd[xdi--] = 0;
1419
- k = 1;
1420
- }
1421
- }
1422
- }
1423
- for (i = xd.length; xd[--i] === 0; )
1424
- xd.pop();
329
+ if (this._mantissa === 0n) {
330
+ return _BigDecimal._create(0n, 0, SpecialValue.NONE, !this._negativeZero);
1425
331
  }
1426
- if (external) {
1427
- if (x.e > Ctor.maxE) {
1428
- x.d = null;
1429
- x.e = NaN;
1430
- } else if (x.e < Ctor.minE) {
1431
- x.e = 0;
1432
- x.d = [0];
332
+ return _BigDecimal._create(-this._mantissa, this._exponent, SpecialValue.NONE, false);
333
+ }
334
+ pow(n) {
335
+ if (this._special === SpecialValue.NAN)
336
+ return this;
337
+ if (n === 0)
338
+ return new _BigDecimal(1);
339
+ if (n < 0) {
340
+ return new _BigDecimal(1).div(this.pow(-n));
1433
341
  }
1434
- }
1435
- return x;
1436
- }
1437
- function finiteToString(x, isExp, sd) {
1438
- if (!x.isFinite())
1439
- return nonFiniteToString(x);
1440
- var k, e = x.e, str = digitsToString(x.d), len = str.length;
1441
- if (isExp) {
1442
- if (sd && (k = sd - len) > 0) {
1443
- str = str.charAt(0) + "." + str.slice(1) + getZeroString(k);
1444
- } else if (len > 1) {
1445
- str = str.charAt(0) + "." + str.slice(1);
342
+ if (this._special === SpecialValue.POSITIVE_INFINITY)
343
+ return this;
344
+ if (this._special === SpecialValue.NEGATIVE_INFINITY) {
345
+ return n % 2 === 0 ? _BigDecimal._create(0n, 0, SpecialValue.POSITIVE_INFINITY, false) : this;
1446
346
  }
1447
- str = str + (x.e < 0 ? "e" : "e+") + x.e;
1448
- } else if (e < 0) {
1449
- str = "0." + getZeroString(-e - 1) + str;
1450
- if (sd && (k = sd - len) > 0)
1451
- str += getZeroString(k);
1452
- } else if (e >= len) {
1453
- str += getZeroString(e + 1 - len);
1454
- if (sd && (k = sd - e - 1) > 0)
1455
- str = str + "." + getZeroString(k);
1456
- } else {
1457
- if ((k = e + 1) < len)
1458
- str = str.slice(0, k) + "." + str.slice(k);
1459
- if (sd && (k = sd - len) > 0) {
1460
- if (e + 1 === len)
1461
- str += ".";
1462
- str += getZeroString(k);
347
+ if (this._mantissa === 0n)
348
+ return new _BigDecimal(0);
349
+ const m = this._mantissa ** BigInt(n);
350
+ const e = this._exponent * n;
351
+ const [nm, ne] = removeTrailingZeros(m, e);
352
+ return _BigDecimal._create(nm, ne, SpecialValue.NONE, false);
353
+ }
354
+ floor() {
355
+ if (this._special !== SpecialValue.NONE)
356
+ return this;
357
+ if (this._mantissa === 0n)
358
+ return this;
359
+ if (this._exponent >= 0)
360
+ return this;
361
+ const divisor = bigintPow10(-this._exponent);
362
+ const m = this._mantissa;
363
+ let q = m / divisor;
364
+ if (m < 0n && m % divisor !== 0n) {
365
+ q -= 1n;
1463
366
  }
1464
- }
1465
- return str;
1466
- }
1467
- function getBase10Exponent(digits, e) {
1468
- var w = digits[0];
1469
- for (e *= LOG_BASE; w >= 10; w /= 10)
1470
- e++;
1471
- return e;
1472
- }
1473
- function getLn10(Ctor, sd, pr) {
1474
- if (sd > LN10_PRECISION) {
1475
- external = true;
1476
- if (pr)
1477
- Ctor.precision = pr;
1478
- throw Error(precisionLimitExceeded);
1479
- }
1480
- return finalise(new Ctor(LN10), sd, 1, true);
1481
- }
1482
- function getPi(Ctor, sd, rm) {
1483
- if (sd > PI_PRECISION)
1484
- throw Error(precisionLimitExceeded);
1485
- return finalise(new Ctor(PI), sd, rm, true);
1486
- }
1487
- function getPrecision(digits) {
1488
- var w = digits.length - 1, len = w * LOG_BASE + 1;
1489
- w = digits[w];
1490
- if (w) {
1491
- for (; w % 10 == 0; w /= 10)
1492
- len--;
1493
- for (w = digits[0]; w >= 10; w /= 10)
1494
- len++;
1495
- }
1496
- return len;
1497
- }
1498
- function getZeroString(k) {
1499
- var zs = "";
1500
- for (; k--; )
1501
- zs += "0";
1502
- return zs;
1503
- }
1504
- function intPow(Ctor, x, n, pr) {
1505
- var isTruncated, r = new Ctor(1), k = Math.ceil(pr / LOG_BASE + 4);
1506
- external = false;
1507
- for (; ; ) {
1508
- if (n % 2) {
1509
- r = r.times(x);
1510
- if (truncate(r.d, k))
1511
- isTruncated = true;
367
+ if (q === 0n) {
368
+ const negZero = this._mantissa < 0n;
369
+ return _BigDecimal._create(0n, 0, SpecialValue.NONE, negZero);
1512
370
  }
1513
- n = mathfloor(n / 2);
1514
- if (n === 0) {
1515
- n = r.d.length - 1;
1516
- if (isTruncated && r.d[n] === 0)
1517
- ++r.d[n];
1518
- break;
371
+ const [nm, ne] = removeTrailingZeros(q, 0);
372
+ return _BigDecimal._create(nm, ne, SpecialValue.NONE, false);
373
+ }
374
+ ceil() {
375
+ if (this._special !== SpecialValue.NONE)
376
+ return this;
377
+ if (this._mantissa === 0n)
378
+ return this;
379
+ if (this._exponent >= 0)
380
+ return this;
381
+ const divisor = bigintPow10(-this._exponent);
382
+ const m = this._mantissa;
383
+ let q = m / divisor;
384
+ if (m > 0n && m % divisor !== 0n) {
385
+ q += 1n;
1519
386
  }
1520
- x = x.times(x);
1521
- truncate(x.d, k);
1522
- }
1523
- external = true;
1524
- return r;
1525
- }
1526
- function isOdd(n) {
1527
- return n.d[n.d.length - 1] & 1;
1528
- }
1529
- function maxOrMin(Ctor, args, n) {
1530
- var k, y, x = new Ctor(args[0]), i = 0;
1531
- for (; ++i < args.length; ) {
1532
- y = new Ctor(args[i]);
1533
- if (!y.s) {
1534
- x = y;
1535
- break;
387
+ if (q === 0n) {
388
+ return _BigDecimal._create(0n, 0, SpecialValue.NONE, false);
1536
389
  }
1537
- k = x.cmp(y);
1538
- if (k === n || k === 0 && x.s === n) {
1539
- x = y;
390
+ const [nm, ne] = removeTrailingZeros(q, 0);
391
+ return _BigDecimal._create(nm, ne, SpecialValue.NONE, false);
392
+ }
393
+ log(base) {
394
+ if (this._special === SpecialValue.NAN)
395
+ return this;
396
+ if (this._special === SpecialValue.NEGATIVE_INFINITY) {
397
+ return _BigDecimal._create(0n, 0, SpecialValue.NAN, false);
1540
398
  }
1541
- }
1542
- return x;
1543
- }
1544
- function naturalExponential(x, sd) {
1545
- var denominator, guard, j, pow2, sum2, t, wpr, rep = 0, i = 0, k = 0, Ctor = x.constructor, rm = Ctor.rounding, pr = Ctor.precision;
1546
- if (!x.d || !x.d[0] || x.e > 17) {
1547
- return new Ctor(x.d ? !x.d[0] ? 1 : x.s < 0 ? 0 : 1 / 0 : x.s ? x.s < 0 ? 0 : x : 0 / 0);
1548
- }
1549
- if (sd == null) {
1550
- external = false;
1551
- wpr = pr;
1552
- } else {
1553
- wpr = sd;
1554
- }
1555
- t = new Ctor(0.03125);
1556
- while (x.e > -2) {
1557
- x = x.times(t);
1558
- k += 5;
1559
- }
1560
- guard = Math.log(mathpow(2, k)) / Math.LN10 * 2 + 5 | 0;
1561
- wpr += guard;
1562
- denominator = pow2 = sum2 = new Ctor(1);
1563
- Ctor.precision = wpr;
1564
- for (; ; ) {
1565
- pow2 = finalise(pow2.times(x), wpr, 1);
1566
- denominator = denominator.times(++i);
1567
- t = sum2.plus(divide(pow2, denominator, wpr, 1));
1568
- if (digitsToString(t.d).slice(0, wpr) === digitsToString(sum2.d).slice(0, wpr)) {
1569
- j = k;
1570
- while (j--)
1571
- sum2 = finalise(sum2.times(sum2), wpr, 1);
1572
- if (sd == null) {
1573
- if (rep < 3 && checkRoundingDigits(sum2.d, wpr - guard, rm, rep)) {
1574
- Ctor.precision = wpr += 10;
1575
- denominator = pow2 = t = new Ctor(1);
1576
- i = 0;
1577
- rep++;
1578
- } else {
1579
- return finalise(sum2, Ctor.precision = pr, rm, external = true);
1580
- }
1581
- } else {
1582
- Ctor.precision = pr;
1583
- return sum2;
1584
- }
399
+ if (this._special === SpecialValue.POSITIVE_INFINITY) {
400
+ return _BigDecimal._create(0n, 0, SpecialValue.POSITIVE_INFINITY, false);
1585
401
  }
1586
- sum2 = t;
1587
- }
1588
- }
1589
- function naturalLogarithm(y, sd) {
1590
- var c, c0, denominator, e, numerator, rep, sum2, t, wpr, x1, x2, n = 1, guard = 10, x = y, xd = x.d, Ctor = x.constructor, rm = Ctor.rounding, pr = Ctor.precision;
1591
- if (x.s < 0 || !xd || !xd[0] || !x.e && xd[0] == 1 && xd.length == 1) {
1592
- return new Ctor(xd && !xd[0] ? -1 / 0 : x.s != 1 ? NaN : xd ? 0 : x);
1593
- }
1594
- if (sd == null) {
1595
- external = false;
1596
- wpr = pr;
1597
- } else {
1598
- wpr = sd;
1599
- }
1600
- Ctor.precision = wpr += guard;
1601
- c = digitsToString(xd);
1602
- c0 = c.charAt(0);
1603
- if (Math.abs(e = x.e) < 15e14) {
1604
- while (c0 < 7 && c0 != 1 || c0 == 1 && c.charAt(1) > 3) {
1605
- x = x.times(y);
1606
- c = digitsToString(x.d);
1607
- c0 = c.charAt(0);
1608
- n++;
402
+ if (this._mantissa < 0n) {
403
+ return _BigDecimal._create(0n, 0, SpecialValue.NAN, false);
1609
404
  }
1610
- e = x.e;
1611
- if (c0 > 1) {
1612
- x = new Ctor("0." + c);
1613
- e++;
1614
- } else {
1615
- x = new Ctor(c0 + "." + c.slice(1));
405
+ if (this._mantissa === 0n) {
406
+ return _BigDecimal._create(0n, 0, SpecialValue.NEGATIVE_INFINITY, false);
1616
407
  }
1617
- } else {
1618
- t = getLn10(Ctor, wpr + 2, pr).times(e + "");
1619
- x = naturalLogarithm(new Ctor(c0 + "." + c.slice(1)), wpr - guard).plus(t);
1620
- Ctor.precision = pr;
1621
- return sd == null ? finalise(x, pr, rm, external = true) : x;
1622
- }
1623
- x1 = x;
1624
- sum2 = numerator = x = divide(x.minus(1), x.plus(1), wpr, 1);
1625
- x2 = finalise(x.times(x), wpr, 1);
1626
- denominator = 3;
1627
- for (; ; ) {
1628
- numerator = finalise(numerator.times(x2), wpr, 1);
1629
- t = sum2.plus(divide(numerator, new Ctor(denominator), wpr, 1));
1630
- if (digitsToString(t.d).slice(0, wpr) === digitsToString(sum2.d).slice(0, wpr)) {
1631
- sum2 = sum2.times(2);
1632
- if (e !== 0)
1633
- sum2 = sum2.plus(getLn10(Ctor, wpr + 2, pr).times(e + ""));
1634
- sum2 = divide(sum2, new Ctor(n), wpr, 1);
1635
- if (sd == null) {
1636
- if (checkRoundingDigits(sum2.d, wpr - guard, rm, rep)) {
1637
- Ctor.precision = wpr += guard;
1638
- t = numerator = x = divide(x1.minus(1), x1.plus(1), wpr, 1);
1639
- x2 = finalise(x.times(x), wpr, 1);
1640
- denominator = rep = 1;
1641
- } else {
1642
- return finalise(sum2, Ctor.precision = pr, rm, external = true);
1643
- }
1644
- } else {
1645
- Ctor.precision = pr;
1646
- return sum2;
1647
- }
408
+ if (base === 10) {
409
+ return this._log10();
1648
410
  }
1649
- sum2 = t;
1650
- denominator += 2;
1651
- }
1652
- }
1653
- function nonFiniteToString(x) {
1654
- return String(x.s * x.s / 0);
1655
- }
1656
- function parseDecimal(x, str) {
1657
- var e, i, len;
1658
- if ((e = str.indexOf(".")) > -1)
1659
- str = str.replace(".", "");
1660
- if ((i = str.search(/e/i)) > 0) {
1661
- if (e < 0)
1662
- e = i;
1663
- e += +str.slice(i + 1);
1664
- str = str.substring(0, i);
1665
- } else if (e < 0) {
1666
- e = str.length;
1667
- }
1668
- for (i = 0; str.charCodeAt(i) === 48; i++)
1669
- ;
1670
- for (len = str.length; str.charCodeAt(len - 1) === 48; --len)
1671
- ;
1672
- str = str.slice(i, len);
1673
- if (str) {
1674
- len -= i;
1675
- x.e = e = e - i - 1;
1676
- x.d = [];
1677
- i = (e + 1) % LOG_BASE;
1678
- if (e < 0)
1679
- i += LOG_BASE;
1680
- if (i < len) {
1681
- if (i)
1682
- x.d.push(+str.slice(0, i));
1683
- for (len -= LOG_BASE; i < len; )
1684
- x.d.push(+str.slice(i, i += LOG_BASE));
1685
- str = str.slice(i);
1686
- i = LOG_BASE - str.length;
411
+ const log10x = this._log10();
412
+ const log10b = new _BigDecimal(Math.log10(base));
413
+ return log10x.div(log10b);
414
+ }
415
+ _log10() {
416
+ const absMantissa = bigintAbs(this._mantissa);
417
+ const digits = digitCount(absMantissa);
418
+ let log10Mantissa;
419
+ if (digits <= 15) {
420
+ log10Mantissa = Math.log10(Number(absMantissa));
1687
421
  } else {
1688
- i -= len;
422
+ const shift = digits - 17;
423
+ const leading = absMantissa / bigintPow10(shift);
424
+ log10Mantissa = Math.log10(Number(leading)) + shift;
1689
425
  }
1690
- for (; i--; )
1691
- str += "0";
1692
- x.d.push(+str);
1693
- if (external) {
1694
- if (x.e > x.constructor.maxE) {
1695
- x.d = null;
1696
- x.e = NaN;
1697
- } else if (x.e < x.constructor.minE) {
1698
- x.e = 0;
1699
- x.d = [0];
1700
- }
426
+ const totalLog10 = log10Mantissa + this._exponent;
427
+ return new _BigDecimal(totalLog10);
428
+ }
429
+ // --- Comparison ---
430
+ eq(y) {
431
+ const other = _BigDecimal._coerce(y);
432
+ if (this._special === SpecialValue.NAN || other._special === SpecialValue.NAN)
433
+ return false;
434
+ if (this._special !== other._special)
435
+ return false;
436
+ if (this._special !== SpecialValue.NONE)
437
+ return true;
438
+ if (this._mantissa === 0n && other._mantissa === 0n)
439
+ return true;
440
+ return this._mantissa === other._mantissa && this._exponent === other._exponent;
441
+ }
442
+ _compareTo(other) {
443
+ if (this._special === SpecialValue.NAN || other._special === SpecialValue.NAN) {
444
+ return NaN;
1701
445
  }
1702
- } else {
1703
- x.e = 0;
1704
- x.d = [0];
1705
- }
1706
- return x;
1707
- }
1708
- function parseOther(x, str) {
1709
- var base, Ctor, divisor, i, isFloat, len, p, xd, xe;
1710
- if (str.indexOf("_") > -1) {
1711
- str = str.replace(/(\d)_(?=\d)/g, "$1");
1712
- if (isDecimal.test(str))
1713
- return parseDecimal(x, str);
1714
- } else if (str === "Infinity" || str === "NaN") {
1715
- if (!+str)
1716
- x.s = NaN;
1717
- x.e = NaN;
1718
- x.d = null;
1719
- return x;
1720
- }
1721
- if (isHex.test(str)) {
1722
- base = 16;
1723
- str = str.toLowerCase();
1724
- } else if (isBinary.test(str)) {
1725
- base = 2;
1726
- } else if (isOctal.test(str)) {
1727
- base = 8;
1728
- } else {
1729
- throw Error(invalidArgument + str);
1730
- }
1731
- i = str.search(/p/i);
1732
- if (i > 0) {
1733
- p = +str.slice(i + 1);
1734
- str = str.substring(2, i);
1735
- } else {
1736
- str = str.slice(2);
1737
- }
1738
- i = str.indexOf(".");
1739
- isFloat = i >= 0;
1740
- Ctor = x.constructor;
1741
- if (isFloat) {
1742
- str = str.replace(".", "");
1743
- len = str.length;
1744
- i = len - i;
1745
- divisor = intPow(Ctor, new Ctor(base), i, i * 2);
1746
- }
1747
- xd = convertBase(str, base, BASE);
1748
- xe = xd.length - 1;
1749
- for (i = xe; xd[i] === 0; --i)
1750
- xd.pop();
1751
- if (i < 0)
1752
- return new Ctor(x.s * 0);
1753
- x.e = getBase10Exponent(xd, xe);
1754
- x.d = xd;
1755
- external = false;
1756
- if (isFloat)
1757
- x = divide(x, divisor, len * 4);
1758
- if (p)
1759
- x = x.times(Math.abs(p) < 54 ? mathpow(2, p) : Decimal.pow(2, p));
1760
- external = true;
1761
- return x;
1762
- }
1763
- function sine(Ctor, x) {
1764
- var k, len = x.d.length;
1765
- if (len < 3) {
1766
- return x.isZero() ? x : taylorSeries(Ctor, 2, x, x);
1767
- }
1768
- k = 1.4 * Math.sqrt(len);
1769
- k = k > 16 ? 16 : k | 0;
1770
- x = x.times(1 / tinyPow(5, k));
1771
- x = taylorSeries(Ctor, 2, x, x);
1772
- var sin2_x, d5 = new Ctor(5), d16 = new Ctor(16), d20 = new Ctor(20);
1773
- for (; k--; ) {
1774
- sin2_x = x.times(x);
1775
- x = x.times(d5.plus(sin2_x.times(d16.times(sin2_x).minus(d20))));
1776
- }
1777
- return x;
1778
- }
1779
- function taylorSeries(Ctor, n, x, y, isHyperbolic) {
1780
- var j, t, u, x2, i = 1, pr = Ctor.precision, k = Math.ceil(pr / LOG_BASE);
1781
- external = false;
1782
- x2 = x.times(x);
1783
- u = new Ctor(y);
1784
- for (; ; ) {
1785
- t = divide(u.times(x2), new Ctor(n++ * n++), pr, 1);
1786
- u = isHyperbolic ? y.plus(t) : y.minus(t);
1787
- y = divide(t.times(x2), new Ctor(n++ * n++), pr, 1);
1788
- t = u.plus(y);
1789
- if (t.d[k] !== void 0) {
1790
- for (j = k; t.d[j] === u.d[j] && j--; )
1791
- ;
1792
- if (j == -1)
1793
- break;
446
+ if (this._special === SpecialValue.POSITIVE_INFINITY) {
447
+ return other._special === SpecialValue.POSITIVE_INFINITY ? 0 : 1;
1794
448
  }
1795
- j = u;
1796
- u = y;
1797
- y = t;
1798
- t = j;
1799
- i++;
1800
- }
1801
- external = true;
1802
- t.d.length = k + 1;
1803
- return t;
1804
- }
1805
- function tinyPow(b, e) {
1806
- var n = b;
1807
- while (--e)
1808
- n *= b;
1809
- return n;
1810
- }
1811
- function toLessThanHalfPi(Ctor, x) {
1812
- var t, isNeg = x.s < 0, pi = getPi(Ctor, Ctor.precision, 1), halfPi = pi.times(0.5);
1813
- x = x.abs();
1814
- if (x.lte(halfPi)) {
1815
- quadrant = isNeg ? 4 : 1;
1816
- return x;
1817
- }
1818
- t = x.divToInt(pi);
1819
- if (t.isZero()) {
1820
- quadrant = isNeg ? 3 : 2;
1821
- } else {
1822
- x = x.minus(t.times(pi));
1823
- if (x.lte(halfPi)) {
1824
- quadrant = isOdd(t) ? isNeg ? 2 : 3 : isNeg ? 4 : 1;
1825
- return x;
449
+ if (this._special === SpecialValue.NEGATIVE_INFINITY) {
450
+ return other._special === SpecialValue.NEGATIVE_INFINITY ? 0 : -1;
1826
451
  }
1827
- quadrant = isOdd(t) ? isNeg ? 1 : 4 : isNeg ? 3 : 2;
1828
- }
1829
- return x.minus(pi).abs();
1830
- }
1831
- function toStringBinary(x, baseOut, sd, rm) {
1832
- var base, e, i, k, len, roundUp, str, xd, y, Ctor = x.constructor, isExp = sd !== void 0;
1833
- if (isExp) {
1834
- checkInt32(sd, 1, MAX_DIGITS);
1835
- if (rm === void 0)
1836
- rm = Ctor.rounding;
1837
- else
1838
- checkInt32(rm, 0, 8);
1839
- } else {
1840
- sd = Ctor.precision;
1841
- rm = Ctor.rounding;
1842
- }
1843
- if (!x.isFinite()) {
1844
- str = nonFiniteToString(x);
1845
- } else {
1846
- str = finiteToString(x);
1847
- i = str.indexOf(".");
1848
- if (isExp) {
1849
- base = 2;
1850
- if (baseOut == 16) {
1851
- sd = sd * 4 - 3;
1852
- } else if (baseOut == 8) {
1853
- sd = sd * 3 - 2;
1854
- }
1855
- } else {
1856
- base = baseOut;
452
+ if (other._special === SpecialValue.POSITIVE_INFINITY)
453
+ return -1;
454
+ if (other._special === SpecialValue.NEGATIVE_INFINITY)
455
+ return 1;
456
+ const thisZero = this._mantissa === 0n;
457
+ const otherZero = other._mantissa === 0n;
458
+ if (thisZero && otherZero)
459
+ return 0;
460
+ if (thisZero)
461
+ return other._mantissa > 0n ? -1 : 1;
462
+ if (otherZero)
463
+ return this._mantissa > 0n ? 1 : -1;
464
+ const thisNeg = this._mantissa < 0n;
465
+ const otherNeg = other._mantissa < 0n;
466
+ if (thisNeg !== otherNeg)
467
+ return thisNeg ? -1 : 1;
468
+ let m1 = this._mantissa;
469
+ let m2 = other._mantissa;
470
+ const e1 = this._exponent;
471
+ const e2 = other._exponent;
472
+ const minE = Math.min(e1, e2);
473
+ if (e1 > minE)
474
+ m1 *= bigintPow10(e1 - minE);
475
+ if (e2 > minE)
476
+ m2 *= bigintPow10(e2 - minE);
477
+ if (m1 < m2)
478
+ return -1;
479
+ if (m1 > m2)
480
+ return 1;
481
+ return 0;
482
+ }
483
+ lessThan(y) {
484
+ const c = this._compareTo(_BigDecimal._coerce(y));
485
+ return c === -1;
486
+ }
487
+ greaterThan(y) {
488
+ const c = this._compareTo(_BigDecimal._coerce(y));
489
+ return c === 1;
490
+ }
491
+ lessThanOrEqualTo(y) {
492
+ const c = this._compareTo(_BigDecimal._coerce(y));
493
+ return c === 0 || c === -1;
494
+ }
495
+ greaterThanOrEqualTo(y) {
496
+ const c = this._compareTo(_BigDecimal._coerce(y));
497
+ return c === 0 || c === 1;
498
+ }
499
+ // --- Queries ---
500
+ isZero() {
501
+ return this._special === SpecialValue.NONE && this._mantissa === 0n;
502
+ }
503
+ isNaN() {
504
+ return this._special === SpecialValue.NAN;
505
+ }
506
+ isFinite() {
507
+ return this._special === SpecialValue.NONE;
508
+ }
509
+ isNegative() {
510
+ if (this._special === SpecialValue.NAN)
511
+ return false;
512
+ if (this._special === SpecialValue.NEGATIVE_INFINITY)
513
+ return true;
514
+ if (this._special === SpecialValue.POSITIVE_INFINITY)
515
+ return false;
516
+ if (this._mantissa === 0n)
517
+ return this._negativeZero;
518
+ return this._mantissa < 0n;
519
+ }
520
+ isPositive() {
521
+ if (this._special === SpecialValue.NAN)
522
+ return false;
523
+ if (this._special === SpecialValue.POSITIVE_INFINITY)
524
+ return true;
525
+ if (this._special === SpecialValue.NEGATIVE_INFINITY)
526
+ return false;
527
+ if (this._mantissa === 0n)
528
+ return !this._negativeZero;
529
+ return this._mantissa > 0n;
530
+ }
531
+ isInteger() {
532
+ if (this._special !== SpecialValue.NONE)
533
+ return false;
534
+ if (this._mantissa === 0n)
535
+ return true;
536
+ return this._exponent >= 0;
537
+ }
538
+ // --- Conversion ---
539
+ toJSON() {
540
+ return this.toString();
541
+ }
542
+ toNumber() {
543
+ if (this._special === SpecialValue.NAN)
544
+ return NaN;
545
+ if (this._special === SpecialValue.POSITIVE_INFINITY)
546
+ return Infinity;
547
+ if (this._special === SpecialValue.NEGATIVE_INFINITY)
548
+ return -Infinity;
549
+ if (this._mantissa === 0n)
550
+ return this._negativeZero ? -0 : 0;
551
+ return Number(this.toString());
552
+ }
553
+ toString() {
554
+ if (this._special === SpecialValue.NAN)
555
+ return "NaN";
556
+ if (this._special === SpecialValue.POSITIVE_INFINITY)
557
+ return "Infinity";
558
+ if (this._special === SpecialValue.NEGATIVE_INFINITY)
559
+ return "-Infinity";
560
+ if (this._mantissa === 0n)
561
+ return "0";
562
+ const negative = this._mantissa < 0n;
563
+ const absStr = bigintAbs(this._mantissa).toString();
564
+ const prefix = negative ? "-" : "";
565
+ if (this._exponent === 0) {
566
+ return prefix + absStr;
1857
567
  }
1858
- if (i >= 0) {
1859
- str = str.replace(".", "");
1860
- y = new Ctor(1);
1861
- y.e = str.length - i;
1862
- y.d = convertBase(finiteToString(y), 10, base);
1863
- y.e = y.d.length;
568
+ if (this._exponent > 0) {
569
+ return prefix + absStr + "0".repeat(this._exponent);
1864
570
  }
1865
- xd = convertBase(str, 10, base);
1866
- e = len = xd.length;
1867
- for (; xd[--len] == 0; )
1868
- xd.pop();
1869
- if (!xd[0]) {
1870
- str = isExp ? "0p+0" : "0";
571
+ const decimalPlaces = -this._exponent;
572
+ if (decimalPlaces < absStr.length) {
573
+ const intPart = absStr.slice(0, absStr.length - decimalPlaces);
574
+ const fracPart = absStr.slice(absStr.length - decimalPlaces);
575
+ return prefix + intPart + "." + fracPart;
1871
576
  } else {
1872
- if (i < 0) {
1873
- e--;
1874
- } else {
1875
- x = new Ctor(x);
1876
- x.d = xd;
1877
- x.e = e;
1878
- x = divide(x, y, sd, rm, 0, base);
1879
- xd = x.d;
1880
- e = x.e;
1881
- roundUp = inexact;
1882
- }
1883
- i = xd[sd];
1884
- k = base / 2;
1885
- roundUp = roundUp || xd[sd + 1] !== void 0;
1886
- roundUp = rm < 4 ? (i !== void 0 || roundUp) && (rm === 0 || rm === (x.s < 0 ? 3 : 2)) : i > k || i === k && (rm === 4 || roundUp || rm === 6 && xd[sd - 1] & 1 || rm === (x.s < 0 ? 8 : 7));
1887
- xd.length = sd;
1888
- if (roundUp) {
1889
- for (; ++xd[--sd] > base - 1; ) {
1890
- xd[sd] = 0;
1891
- if (!sd) {
1892
- ++e;
1893
- xd.unshift(1);
1894
- }
1895
- }
1896
- }
1897
- for (len = xd.length; !xd[len - 1]; --len)
1898
- ;
1899
- for (i = 0, str = ""; i < len; i++)
1900
- str += NUMERALS.charAt(xd[i]);
1901
- if (isExp) {
1902
- if (len > 1) {
1903
- if (baseOut == 16 || baseOut == 8) {
1904
- i = baseOut == 16 ? 4 : 3;
1905
- for (--len; len % i; len++)
1906
- str += "0";
1907
- xd = convertBase(str, base, baseOut);
1908
- for (len = xd.length; !xd[len - 1]; --len)
1909
- ;
1910
- for (i = 1, str = "1."; i < len; i++)
1911
- str += NUMERALS.charAt(xd[i]);
1912
- } else {
1913
- str = str.charAt(0) + "." + str.slice(1);
1914
- }
1915
- }
1916
- str = str + (e < 0 ? "p" : "p+") + e;
1917
- } else if (e < 0) {
1918
- for (; ++e; )
1919
- str = "0" + str;
1920
- str = "0." + str;
1921
- } else {
1922
- if (++e > len)
1923
- for (e -= len; e--; )
1924
- str += "0";
1925
- else if (e < len)
1926
- str = str.slice(0, e) + "." + str.slice(e);
1927
- }
1928
- }
1929
- str = (baseOut == 16 ? "0x" : baseOut == 2 ? "0b" : baseOut == 8 ? "0o" : "") + str;
1930
- }
1931
- return x.s < 0 ? "-" + str : str;
1932
- }
1933
- function truncate(arr, len) {
1934
- if (arr.length > len) {
1935
- arr.length = len;
1936
- return true;
1937
- }
1938
- }
1939
- function abs(x) {
1940
- return new this(x).abs();
1941
- }
1942
- function acos(x) {
1943
- return new this(x).acos();
1944
- }
1945
- function acosh(x) {
1946
- return new this(x).acosh();
1947
- }
1948
- function add(x, y) {
1949
- return new this(x).plus(y);
1950
- }
1951
- function asin(x) {
1952
- return new this(x).asin();
1953
- }
1954
- function asinh(x) {
1955
- return new this(x).asinh();
1956
- }
1957
- function atan(x) {
1958
- return new this(x).atan();
1959
- }
1960
- function atanh(x) {
1961
- return new this(x).atanh();
1962
- }
1963
- function atan2(y, x) {
1964
- y = new this(y);
1965
- x = new this(x);
1966
- var r, pr = this.precision, rm = this.rounding, wpr = pr + 4;
1967
- if (!y.s || !x.s) {
1968
- r = new this(NaN);
1969
- } else if (!y.d && !x.d) {
1970
- r = getPi(this, wpr, 1).times(x.s > 0 ? 0.25 : 0.75);
1971
- r.s = y.s;
1972
- } else if (!x.d || y.isZero()) {
1973
- r = x.s < 0 ? getPi(this, pr, rm) : new this(0);
1974
- r.s = y.s;
1975
- } else if (!y.d || x.isZero()) {
1976
- r = getPi(this, wpr, 1).times(0.5);
1977
- r.s = y.s;
1978
- } else if (x.s < 0) {
1979
- this.precision = wpr;
1980
- this.rounding = 1;
1981
- r = this.atan(divide(y, x, wpr, 1));
1982
- x = getPi(this, wpr, 1);
1983
- this.precision = pr;
1984
- this.rounding = rm;
1985
- r = y.s < 0 ? r.minus(x) : r.plus(x);
1986
- } else {
1987
- r = this.atan(divide(y, x, wpr, 1));
1988
- }
1989
- return r;
1990
- }
1991
- function cbrt(x) {
1992
- return new this(x).cbrt();
1993
- }
1994
- function ceil(x) {
1995
- return finalise(x = new this(x), x.e + 1, 2);
1996
- }
1997
- function clamp(x, min2, max2) {
1998
- return new this(x).clamp(min2, max2);
1999
- }
2000
- function config(obj) {
2001
- if (!obj || typeof obj !== "object")
2002
- throw Error(decimalError + "Object expected");
2003
- var i, p, v, useDefaults = obj.defaults === true, ps = [
2004
- "precision",
2005
- 1,
2006
- MAX_DIGITS,
2007
- "rounding",
2008
- 0,
2009
- 8,
2010
- "toExpNeg",
2011
- -EXP_LIMIT,
2012
- 0,
2013
- "toExpPos",
2014
- 0,
2015
- EXP_LIMIT,
2016
- "maxE",
2017
- 0,
2018
- EXP_LIMIT,
2019
- "minE",
2020
- -EXP_LIMIT,
2021
- 0,
2022
- "modulo",
2023
- 0,
2024
- 9
2025
- ];
2026
- for (i = 0; i < ps.length; i += 3) {
2027
- if (p = ps[i], useDefaults)
2028
- this[p] = DEFAULTS[p];
2029
- if ((v = obj[p]) !== void 0) {
2030
- if (mathfloor(v) === v && v >= ps[i + 1] && v <= ps[i + 2])
2031
- this[p] = v;
2032
- else
2033
- throw Error(invalidArgument + p + ": " + v);
577
+ const leadingZeros = decimalPlaces - absStr.length;
578
+ return prefix + "0." + "0".repeat(leadingZeros) + absStr;
2034
579
  }
2035
580
  }
2036
- if (p = "crypto", useDefaults)
2037
- this[p] = DEFAULTS[p];
2038
- if ((v = obj[p]) !== void 0) {
2039
- if (v === true || v === false || v === 0 || v === 1) {
2040
- if (v) {
2041
- if (typeof crypto != "undefined" && crypto && (crypto.getRandomValues || crypto.randomBytes)) {
2042
- this[p] = true;
2043
- } else {
2044
- throw Error(cryptoUnavailable);
2045
- }
2046
- } else {
2047
- this[p] = false;
2048
- }
2049
- } else {
2050
- throw Error(invalidArgument + p + ": " + v);
581
+ // --- Static ---
582
+ static pow(base, exp) {
583
+ const n = typeof exp === "number" ? exp : exp.toNumber();
584
+ if (typeof base === "number" && base === 10) {
585
+ return _BigDecimal._create(1n, n, SpecialValue.NONE, false);
2051
586
  }
587
+ const bd = base instanceof _BigDecimal ? base : new _BigDecimal(base);
588
+ return bd.pow(n);
589
+ }
590
+ static set(_config) {
591
+ }
592
+ // --- Internal helpers ---
593
+ _isSignNegative() {
594
+ if (this._special === SpecialValue.NEGATIVE_INFINITY)
595
+ return true;
596
+ if (this._mantissa < 0n)
597
+ return true;
598
+ if (this._mantissa === 0n)
599
+ return this._negativeZero;
600
+ return false;
2052
601
  }
2053
- return this;
2054
- }
2055
- function cos(x) {
2056
- return new this(x).cos();
2057
- }
2058
- function cosh(x) {
2059
- return new this(x).cosh();
2060
- }
2061
- function clone(obj) {
2062
- var i, p, ps;
2063
- function Decimal2(v) {
2064
- var e, i2, t, x = this;
2065
- if (!(x instanceof Decimal2))
2066
- return new Decimal2(v);
2067
- x.constructor = Decimal2;
2068
- if (isDecimalInstance(v)) {
2069
- x.s = v.s;
2070
- if (external) {
2071
- if (!v.d || v.e > Decimal2.maxE) {
2072
- x.e = NaN;
2073
- x.d = null;
2074
- } else if (v.e < Decimal2.minE) {
2075
- x.e = 0;
2076
- x.d = [0];
2077
- } else {
2078
- x.e = v.e;
2079
- x.d = v.d.slice();
2080
- }
2081
- } else {
2082
- x.e = v.e;
2083
- x.d = v.d ? v.d.slice() : v.d;
2084
- }
2085
- return;
602
+ _specialArith(other, op) {
603
+ const a = this._special;
604
+ const b = other._special;
605
+ if (a === SpecialValue.NAN || b === SpecialValue.NAN) {
606
+ return _BigDecimal._create(0n, 0, SpecialValue.NAN, false);
2086
607
  }
2087
- t = typeof v;
2088
- if (t === "number") {
2089
- if (v === 0) {
2090
- x.s = 1 / v < 0 ? -1 : 1;
2091
- x.e = 0;
2092
- x.d = [0];
2093
- return;
2094
- }
2095
- if (v < 0) {
2096
- v = -v;
2097
- x.s = -1;
2098
- } else {
2099
- x.s = 1;
2100
- }
2101
- if (v === ~~v && v < 1e7) {
2102
- for (e = 0, i2 = v; i2 >= 10; i2 /= 10)
2103
- e++;
2104
- if (external) {
2105
- if (e > Decimal2.maxE) {
2106
- x.e = NaN;
2107
- x.d = null;
2108
- } else if (e < Decimal2.minE) {
2109
- x.e = 0;
2110
- x.d = [0];
2111
- } else {
2112
- x.e = e;
2113
- x.d = [v];
2114
- }
2115
- } else {
2116
- x.e = e;
2117
- x.d = [v];
608
+ const aNeg = this._isSignNegative();
609
+ const bNeg = other._isSignNegative();
610
+ const aInf = a === SpecialValue.POSITIVE_INFINITY || a === SpecialValue.NEGATIVE_INFINITY;
611
+ const bInf = b === SpecialValue.POSITIVE_INFINITY || b === SpecialValue.NEGATIVE_INFINITY;
612
+ if (op === "times") {
613
+ if (aInf || bInf) {
614
+ if (aInf && other._mantissa === 0n && !bInf || bInf && this._mantissa === 0n && !aInf) {
615
+ return _BigDecimal._create(0n, 0, SpecialValue.NAN, false);
2118
616
  }
2119
- return;
617
+ const neg = aNeg !== bNeg;
618
+ return _BigDecimal._create(0n, 0, neg ? SpecialValue.NEGATIVE_INFINITY : SpecialValue.POSITIVE_INFINITY, false);
2120
619
  }
2121
- if (v * 0 !== 0) {
2122
- if (!v)
2123
- x.s = NaN;
2124
- x.e = NaN;
2125
- x.d = null;
2126
- return;
2127
- }
2128
- return parseDecimal(x, v.toString());
2129
- }
2130
- if (t === "string") {
2131
- if ((i2 = v.charCodeAt(0)) === 45) {
2132
- v = v.slice(1);
2133
- x.s = -1;
2134
- } else {
2135
- if (i2 === 43)
2136
- v = v.slice(1);
2137
- x.s = 1;
2138
- }
2139
- return isDecimal.test(v) ? parseDecimal(x, v) : parseOther(x, v);
2140
620
  }
2141
- if (t === "bigint") {
2142
- if (v < 0) {
2143
- v = -v;
2144
- x.s = -1;
2145
- } else {
2146
- x.s = 1;
621
+ if (op === "div") {
622
+ if (aInf && bInf) {
623
+ return _BigDecimal._create(0n, 0, SpecialValue.NAN, false);
2147
624
  }
2148
- return parseDecimal(x, v.toString());
2149
- }
2150
- throw Error(invalidArgument + v);
2151
- }
2152
- Decimal2.prototype = P;
2153
- Decimal2.ROUND_UP = 0;
2154
- Decimal2.ROUND_DOWN = 1;
2155
- Decimal2.ROUND_CEIL = 2;
2156
- Decimal2.ROUND_FLOOR = 3;
2157
- Decimal2.ROUND_HALF_UP = 4;
2158
- Decimal2.ROUND_HALF_DOWN = 5;
2159
- Decimal2.ROUND_HALF_EVEN = 6;
2160
- Decimal2.ROUND_HALF_CEIL = 7;
2161
- Decimal2.ROUND_HALF_FLOOR = 8;
2162
- Decimal2.EUCLID = 9;
2163
- Decimal2.config = Decimal2.set = config;
2164
- Decimal2.clone = clone;
2165
- Decimal2.isDecimal = isDecimalInstance;
2166
- Decimal2.abs = abs;
2167
- Decimal2.acos = acos;
2168
- Decimal2.acosh = acosh;
2169
- Decimal2.add = add;
2170
- Decimal2.asin = asin;
2171
- Decimal2.asinh = asinh;
2172
- Decimal2.atan = atan;
2173
- Decimal2.atanh = atanh;
2174
- Decimal2.atan2 = atan2;
2175
- Decimal2.cbrt = cbrt;
2176
- Decimal2.ceil = ceil;
2177
- Decimal2.clamp = clamp;
2178
- Decimal2.cos = cos;
2179
- Decimal2.cosh = cosh;
2180
- Decimal2.div = div;
2181
- Decimal2.exp = exp;
2182
- Decimal2.floor = floor;
2183
- Decimal2.hypot = hypot;
2184
- Decimal2.ln = ln;
2185
- Decimal2.log = log;
2186
- Decimal2.log10 = log10;
2187
- Decimal2.log2 = log2;
2188
- Decimal2.max = max;
2189
- Decimal2.min = min;
2190
- Decimal2.mod = mod;
2191
- Decimal2.mul = mul;
2192
- Decimal2.pow = pow;
2193
- Decimal2.random = random;
2194
- Decimal2.round = round;
2195
- Decimal2.sign = sign;
2196
- Decimal2.sin = sin;
2197
- Decimal2.sinh = sinh;
2198
- Decimal2.sqrt = sqrt;
2199
- Decimal2.sub = sub;
2200
- Decimal2.sum = sum;
2201
- Decimal2.tan = tan;
2202
- Decimal2.tanh = tanh;
2203
- Decimal2.trunc = trunc;
2204
- if (obj === void 0)
2205
- obj = {};
2206
- if (obj) {
2207
- if (obj.defaults !== true) {
2208
- ps = ["precision", "rounding", "toExpNeg", "toExpPos", "maxE", "minE", "modulo", "crypto"];
2209
- for (i = 0; i < ps.length; )
2210
- if (!obj.hasOwnProperty(p = ps[i++]))
2211
- obj[p] = this[p];
2212
- }
2213
- }
2214
- Decimal2.config(obj);
2215
- return Decimal2;
2216
- }
2217
- function div(x, y) {
2218
- return new this(x).div(y);
2219
- }
2220
- function exp(x) {
2221
- return new this(x).exp();
2222
- }
2223
- function floor(x) {
2224
- return finalise(x = new this(x), x.e + 1, 3);
2225
- }
2226
- function hypot() {
2227
- var i, n, t = new this(0);
2228
- external = false;
2229
- for (i = 0; i < arguments.length; ) {
2230
- n = new this(arguments[i++]);
2231
- if (!n.d) {
2232
- if (n.s) {
2233
- external = true;
2234
- return new this(1 / 0);
625
+ if (aInf) {
626
+ const neg = aNeg !== bNeg;
627
+ return _BigDecimal._create(0n, 0, neg ? SpecialValue.NEGATIVE_INFINITY : SpecialValue.POSITIVE_INFINITY, false);
2235
628
  }
2236
- t = n;
2237
- } else if (t.d) {
2238
- t = t.plus(n.times(n));
2239
- }
2240
- }
2241
- external = true;
2242
- return t.sqrt();
2243
- }
2244
- function isDecimalInstance(obj) {
2245
- return obj instanceof Decimal || obj && obj.toStringTag === tag || false;
2246
- }
2247
- function ln(x) {
2248
- return new this(x).ln();
2249
- }
2250
- function log(x, y) {
2251
- return new this(x).log(y);
2252
- }
2253
- function log2(x) {
2254
- return new this(x).log(2);
2255
- }
2256
- function log10(x) {
2257
- return new this(x).log(10);
2258
- }
2259
- function max() {
2260
- return maxOrMin(this, arguments, -1);
2261
- }
2262
- function min() {
2263
- return maxOrMin(this, arguments, 1);
2264
- }
2265
- function mod(x, y) {
2266
- return new this(x).mod(y);
2267
- }
2268
- function mul(x, y) {
2269
- return new this(x).mul(y);
2270
- }
2271
- function pow(x, y) {
2272
- return new this(x).pow(y);
2273
- }
2274
- function random(sd) {
2275
- var d, e, k, n, i = 0, r = new this(1), rd = [];
2276
- if (sd === void 0)
2277
- sd = this.precision;
2278
- else
2279
- checkInt32(sd, 1, MAX_DIGITS);
2280
- k = Math.ceil(sd / LOG_BASE);
2281
- if (!this.crypto) {
2282
- for (; i < k; )
2283
- rd[i++] = Math.random() * 1e7 | 0;
2284
- } else if (crypto.getRandomValues) {
2285
- d = crypto.getRandomValues(new Uint32Array(k));
2286
- for (; i < k; ) {
2287
- n = d[i];
2288
- if (n >= 429e7) {
2289
- d[i] = crypto.getRandomValues(new Uint32Array(1))[0];
2290
- } else {
2291
- rd[i++] = n % 1e7;
629
+ if (bInf) {
630
+ const negZero = aNeg !== bNeg;
631
+ return _BigDecimal._create(0n, 0, SpecialValue.NONE, negZero);
2292
632
  }
2293
633
  }
2294
- } else if (crypto.randomBytes) {
2295
- d = crypto.randomBytes(k *= 4);
2296
- for (; i < k; ) {
2297
- n = d[i] + (d[i + 1] << 8) + (d[i + 2] << 16) + ((d[i + 3] & 127) << 24);
2298
- if (n >= 214e7) {
2299
- crypto.randomBytes(4).copy(d, i);
2300
- } else {
2301
- rd.push(n % 1e7);
2302
- i += 4;
634
+ if (op === "plus") {
635
+ if (aInf && bInf) {
636
+ if (aNeg !== bNeg) {
637
+ return _BigDecimal._create(0n, 0, SpecialValue.NAN, false);
638
+ }
639
+ return this;
2303
640
  }
641
+ if (aInf)
642
+ return this;
643
+ if (bInf)
644
+ return other;
2304
645
  }
2305
- i = k / 4;
2306
- } else {
2307
- throw Error(cryptoUnavailable);
2308
- }
2309
- k = rd[--i];
2310
- sd %= LOG_BASE;
2311
- if (k && sd) {
2312
- n = mathpow(10, LOG_BASE - sd);
2313
- rd[i] = (k / n | 0) * n;
2314
- }
2315
- for (; rd[i] === 0; i--)
2316
- rd.pop();
2317
- if (i < 0) {
2318
- e = 0;
2319
- rd = [0];
2320
- } else {
2321
- e = -1;
2322
- for (; rd[0] === 0; e -= LOG_BASE)
2323
- rd.shift();
2324
- for (k = 1, n = rd[0]; n >= 10; n /= 10)
2325
- k++;
2326
- if (k < LOG_BASE)
2327
- e -= LOG_BASE - k;
646
+ return _BigDecimal._create(0n, 0, SpecialValue.NAN, false);
2328
647
  }
2329
- r.e = e;
2330
- r.d = rd;
2331
- return r;
2332
- }
2333
- function round(x) {
2334
- return finalise(x = new this(x), x.e + 1, this.rounding);
2335
- }
2336
- function sign(x) {
2337
- x = new this(x);
2338
- return x.d ? x.d[0] ? x.s : 0 * x.s : x.s || NaN;
2339
- }
2340
- function sin(x) {
2341
- return new this(x).sin();
2342
- }
2343
- function sinh(x) {
2344
- return new this(x).sinh();
2345
- }
2346
- function sqrt(x) {
2347
- return new this(x).sqrt();
2348
- }
2349
- function sub(x, y) {
2350
- return new this(x).sub(y);
2351
- }
2352
- function sum() {
2353
- var i = 0, args = arguments, x = new this(args[i]);
2354
- external = false;
2355
- for (; x.s && ++i < args.length; )
2356
- x = x.plus(args[i]);
2357
- external = true;
2358
- return finalise(x, this.precision, this.rounding);
2359
- }
2360
- function tan(x) {
2361
- return new this(x).tan();
2362
- }
2363
- function tanh(x) {
2364
- return new this(x).tanh();
2365
- }
2366
- function trunc(x) {
2367
- return finalise(x = new this(x), x.e + 1, 1);
2368
- }
2369
- P[Symbol.for("nodejs.util.inspect.custom")] = P.toString;
2370
- P[Symbol.toStringTag] = "Decimal";
2371
- var Decimal = P.constructor = clone(DEFAULTS);
2372
- LN10 = new Decimal(LN10);
2373
- PI = new Decimal(PI);
648
+ };
2374
649
 
2375
650
  // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/constants.js
2376
- var TEN = new Decimal(10);
2377
- var ZERO = new Decimal(0);
2378
- var NEGATIVE_ZERO = new Decimal(-0);
651
+ var TEN = new BigDecimal(10);
652
+ var ZERO = new BigDecimal(0);
653
+ var NEGATIVE_ZERO = new BigDecimal(-0);
2379
654
 
2380
655
  // node_modules/.aspect_rules_js/@formatjs+fast-memoize@0.0.0/node_modules/@formatjs/fast-memoize/index.js
2381
656
  function memoize(fn, options) {
@@ -2595,15 +870,9 @@
2595
870
 
2596
871
  // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/NumberFormat/decimal-cache.js
2597
872
  var getPowerOf10 = memoize((exponent) => {
2598
- return Decimal.pow(10, exponent);
873
+ return BigDecimal.pow(10, exponent);
2599
874
  });
2600
875
 
2601
- // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/NumberFormat/ComputeExponentForMagnitude.js
2602
- Decimal.set({ toExpPos: 100 });
2603
-
2604
- // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/NumberFormat/ToRawFixed.js
2605
- Decimal.set({ toExpPos: 100 });
2606
-
2607
876
  // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/regex.generated.js
2608
877
  var S_UNICODE_REGEX = /[\$\+<->\^`\|~\xA2-\xA6\xA8\xA9\xAC\xAE-\xB1\xB4\xB8\xD7\xF7\u02C2-\u02C5\u02D2-\u02DF\u02E5-\u02EB\u02ED\u02EF-\u02FF\u0375\u0384\u0385\u03F6\u0482\u058D-\u058F\u0606-\u0608\u060B\u060E\u060F\u06DE\u06E9\u06FD\u06FE\u07F6\u07FE\u07FF\u0888\u09F2\u09F3\u09FA\u09FB\u0AF1\u0B70\u0BF3-\u0BFA\u0C7F\u0D4F\u0D79\u0E3F\u0F01-\u0F03\u0F13\u0F15-\u0F17\u0F1A-\u0F1F\u0F34\u0F36\u0F38\u0FBE-\u0FC5\u0FC7-\u0FCC\u0FCE\u0FCF\u0FD5-\u0FD8\u109E\u109F\u1390-\u1399\u166D\u17DB\u1940\u19DE-\u19FF\u1B61-\u1B6A\u1B74-\u1B7C\u1FBD\u1FBF-\u1FC1\u1FCD-\u1FCF\u1FDD-\u1FDF\u1FED-\u1FEF\u1FFD\u1FFE\u2044\u2052\u207A-\u207C\u208A-\u208C\u20A0-\u20C1\u2100\u2101\u2103-\u2106\u2108\u2109\u2114\u2116-\u2118\u211E-\u2123\u2125\u2127\u2129\u212E\u213A\u213B\u2140-\u2144\u214A-\u214D\u214F\u218A\u218B\u2190-\u2307\u230C-\u2328\u232B-\u2429\u2440-\u244A\u249C-\u24E9\u2500-\u2767\u2794-\u27C4\u27C7-\u27E5\u27F0-\u2982\u2999-\u29D7\u29DC-\u29FB\u29FE-\u2B73\u2B76-\u2BFF\u2CE5-\u2CEA\u2E50\u2E51\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFF\u3004\u3012\u3013\u3020\u3036\u3037\u303E\u303F\u309B\u309C\u3190\u3191\u3196-\u319F\u31C0-\u31E5\u31EF\u3200-\u321E\u322A-\u3247\u3250\u3260-\u327F\u328A-\u32B0\u32C0-\u33FF\u4DC0-\u4DFF\uA490-\uA4C6\uA700-\uA716\uA720\uA721\uA789\uA78A\uA828-\uA82B\uA836-\uA839\uAA77-\uAA79\uAB5B\uAB6A\uAB6B\uFB29\uFBB2-\uFBD2\uFD40-\uFD4F\uFD90\uFD91\uFDC8-\uFDCF\uFDFC-\uFDFF\uFE62\uFE64-\uFE66\uFE69\uFF04\uFF0B\uFF1C-\uFF1E\uFF3E\uFF40\uFF5C\uFF5E\uFFE0-\uFFE6\uFFE8-\uFFEE\uFFFC\uFFFD]|\uD800[\uDD37-\uDD3F\uDD79-\uDD89\uDD8C-\uDD8E\uDD90-\uDD9C\uDDA0\uDDD0-\uDDFC]|\uD802[\uDC77\uDC78\uDEC8]|\uD803[\uDD8E\uDD8F\uDED1-\uDED8]|\uD805\uDF3F|\uD807[\uDFD5-\uDFF1]|\uD81A[\uDF3C-\uDF3F\uDF45]|\uD82F\uDC9C|\uD833[\uDC00-\uDCEF\uDCFA-\uDCFC\uDD00-\uDEB3\uDEBA-\uDED0\uDEE0-\uDEF0\uDF50-\uDFC3]|\uD834[\uDC00-\uDCF5\uDD00-\uDD26\uDD29-\uDD64\uDD6A-\uDD6C\uDD83\uDD84\uDD8C-\uDDA9\uDDAE-\uDDEA\uDE00-\uDE41\uDE45\uDF00-\uDF56]|\uD835[\uDEC1\uDEDB\uDEFB\uDF15\uDF35\uDF4F\uDF6F\uDF89\uDFA9\uDFC3]|\uD836[\uDC00-\uDDFF\uDE37-\uDE3A\uDE6D-\uDE74\uDE76-\uDE83\uDE85\uDE86]|\uD838[\uDD4F\uDEFF]|\uD83B[\uDCAC\uDCB0\uDD2E\uDEF0\uDEF1]|\uD83C[\uDC00-\uDC2B\uDC30-\uDC93\uDCA0-\uDCAE\uDCB1-\uDCBF\uDCC1-\uDCCF\uDCD1-\uDCF5\uDD0D-\uDDAD\uDDE6-\uDE02\uDE10-\uDE3B\uDE40-\uDE48\uDE50\uDE51\uDE60-\uDE65\uDF00-\uDFFF]|\uD83D[\uDC00-\uDED8\uDEDC-\uDEEC\uDEF0-\uDEFC\uDF00-\uDFD9\uDFE0-\uDFEB\uDFF0]|\uD83E[\uDC00-\uDC0B\uDC10-\uDC47\uDC50-\uDC59\uDC60-\uDC87\uDC90-\uDCAD\uDCB0-\uDCBB\uDCC0\uDCC1\uDCD0-\uDCD8\uDD00-\uDE57\uDE60-\uDE6D\uDE70-\uDE7C\uDE80-\uDE8A\uDE8E-\uDEC6\uDEC8\uDECD-\uDEDC\uDEDF-\uDEEA\uDEEF-\uDEF8\uDF00-\uDF92\uDF94-\uDFEF\uDFFA]/;
2609
878
 
@@ -5809,9 +4078,8 @@
5809
4078
  var DEFAULT_MATCHING_THRESHOLD = 838;
5810
4079
  var PROCESSED_DATA;
5811
4080
  function processData() {
5812
- var _a, _b;
5813
4081
  if (!PROCESSED_DATA) {
5814
- const paradigmLocales = (_b = (_a = data.supplemental.languageMatching["written-new"][0]) == null ? void 0 : _a.paradigmLocales) == null ? void 0 : _b._locales.split(" ");
4082
+ const paradigmLocales = data.supplemental.languageMatching["written-new"][0]?.paradigmLocales?._locales.split(" ");
5815
4083
  const matchVariables = data.supplemental.languageMatching["written-new"].slice(1, 5);
5816
4084
  const data2 = data.supplemental.languageMatching["written-new"].slice(5);
5817
4085
  const matches = data2.map((d) => {
@@ -5943,7 +4211,7 @@
5943
4211
  try {
5944
4212
  const canonical = Intl.getCanonicalLocales([locale]);
5945
4213
  return canonical[0] || locale;
5946
- } catch (e) {
4214
+ } catch {
5947
4215
  return locale;
5948
4216
  }
5949
4217
  });
@@ -5980,7 +4248,7 @@
5980
4248
  try {
5981
4249
  const candidateMaximized = new Intl.Locale(candidate).maximize().toString();
5982
4250
  distance = candidateMaximized === maximized ? 0 + i * 40 : j * 10 + i * 40;
5983
- } catch (e) {
4251
+ } catch {
5984
4252
  distance = j * 10 + i * 40;
5985
4253
  }
5986
4254
  if (!result.distances[desired]) {
@@ -5996,7 +4264,7 @@
5996
4264
  }
5997
4265
  }
5998
4266
  }
5999
- } catch (e) {
4267
+ } catch {
6000
4268
  }
6001
4269
  }
6002
4270
  if (result.matchedSupportedLocale && lowestDistance === 0) {
@@ -6162,10 +4430,10 @@
6162
4430
  key: subtag,
6163
4431
  value: ""
6164
4432
  };
6165
- if (keywords.find((k2) => k2.key === (keyword == null ? void 0 : keyword.key)) === void 0) {
4433
+ if (keywords.find((k2) => k2.key === keyword?.key) === void 0) {
6166
4434
  keywords.push(keyword);
6167
4435
  }
6168
- } else if ((keyword == null ? void 0 : keyword.value) === "") {
4436
+ } else if (keyword?.value === "") {
6169
4437
  keyword.value = subtag;
6170
4438
  } else {
6171
4439
  invariant2(keyword !== void 0, "Expected keyword to be defined");
@@ -6181,7 +4449,6 @@
6181
4449
 
6182
4450
  // node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/abstract/ResolveLocale.js
6183
4451
  function ResolveLocale(availableLocales, requestedLocales, options, relevantExtensionKeys, localeData, getDefaultLocale) {
6184
- var _a;
6185
4452
  const matcher = options.localeMatcher;
6186
4453
  let r;
6187
4454
  if (matcher === "lookup") {
@@ -6211,7 +4478,7 @@
6211
4478
  }
6212
4479
  let supportedKeywords = [];
6213
4480
  for (const key of relevantExtensionKeys) {
6214
- let keyLocaleData = (_a = foundLocaleData == null ? void 0 : foundLocaleData[key]) != null ? _a : [];
4481
+ let keyLocaleData = foundLocaleData?.[key] ?? [];
6215
4482
  invariant2(Array.isArray(keyLocaleData), `keyLocaleData for ${key} must be an array`);
6216
4483
  let value = keyLocaleData[0];
6217
4484
  invariant2(value === void 0 || typeof value === "string", `value must be a string or undefined`);
@@ -6277,7 +4544,7 @@
6277
4544
 
6278
4545
  // node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/index.js
6279
4546
  function match(requestedLocales, availableLocales, defaultLocale, opts) {
6280
- return ResolveLocale(availableLocales, CanonicalizeLocaleList2(requestedLocales), { localeMatcher: (opts == null ? void 0 : opts.algorithm) || "best fit" }, [], {}, () => defaultLocale).locale;
4547
+ return ResolveLocale(availableLocales, CanonicalizeLocaleList2(requestedLocales), { localeMatcher: opts?.algorithm || "best fit" }, [], {}, () => defaultLocale).locale;
6281
4548
  }
6282
4549
 
6283
4550
  // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/PartitionPattern.js
@@ -6633,7 +4900,7 @@
6633
4900
  enumerable: false,
6634
4901
  configurable: true
6635
4902
  });
6636
- } catch (e) {
4903
+ } catch {
6637
4904
  }
6638
4905
 
6639
4906
  // packages/intl-relativetimeformat/supported-locales.generated.ts
@@ -7224,7 +5491,7 @@
7224
5491
  return "numberingSystem" in new Intl.RelativeTimeFormat(locale || "en", {
7225
5492
  numeric: "auto"
7226
5493
  }).resolvedOptions();
7227
- } catch (e) {
5494
+ } catch {
7228
5495
  return false;
7229
5496
  }
7230
5497
  }
@@ -7242,17 +5509,12 @@
7242
5509
  enumerable: false,
7243
5510
  configurable: true
7244
5511
  });
5512
+ const buf = globalThis.__FORMATJS_RELATIVETIMEFORMAT_DATA__;
5513
+ if (buf) {
5514
+ for (const d of buf)
5515
+ RelativeTimeFormat.__addLocaleData(d);
5516
+ delete globalThis.__FORMATJS_RELATIVETIMEFORMAT_DATA__;
5517
+ }
7245
5518
  }
7246
5519
  })();
7247
- /*! Bundled license information:
7248
-
7249
- decimal.js/decimal.mjs:
7250
- (*!
7251
- * decimal.js v10.6.0
7252
- * An arbitrary-precision Decimal type for JavaScript.
7253
- * https://github.com/MikeMcl/decimal.js
7254
- * Copyright (c) 2025 Michael Mclaughlin <M8ch88l@gmail.com>
7255
- * MIT Licence
7256
- *)
7257
- */
7258
5520
  //# sourceMappingURL=polyfill.iife.js.map