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