types.d.ts 63 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821
  1. // Type definitions for bignumber.js >=8.1.0
  2. // Project: https://github.com/MikeMcl/bignumber.js
  3. // Definitions by: Michael Mclaughlin <https://github.com/MikeMcl>
  4. // Definitions: https://github.com/MikeMcl/bignumber.js
  5. // Documentation: http://mikemcl.github.io/bignumber.js/
  6. //
  7. // class BigNumber
  8. // type BigNumber.Constructor
  9. // type BigNumber.ModuloMode
  10. // type BigNumber.RoundingMode
  11. // type BigNumber.Value
  12. // interface BigNumber.Config
  13. // interface BigNumber.Format
  14. // interface BigNumber.Instance
  15. //
  16. // Example:
  17. //
  18. // import {BigNumber} from "bignumber.js"
  19. // //import BigNumber from "bignumber.js"
  20. //
  21. // let rm: BigNumber.RoundingMode = BigNumber.ROUND_UP;
  22. // let f: BigNumber.Format = { decimalSeparator: ',' };
  23. // let c: BigNumber.Config = { DECIMAL_PLACES: 4, ROUNDING_MODE: rm, FORMAT: f };
  24. // BigNumber.config(c);
  25. //
  26. // let v: BigNumber.Value = '12345.6789';
  27. // let b: BigNumber = new BigNumber(v);
  28. //
  29. // The use of compiler option `--strictNullChecks` is recommended.
  30. declare namespace BigNumber {
  31. /** See `BigNumber.config` (alias `BigNumber.set`) and `BigNumber.clone`. */
  32. interface Config {
  33. /**
  34. * An integer, 0 to 1e+9. Default value: 20.
  35. *
  36. * The maximum number of decimal places of the result of operations involving division, i.e.
  37. * division, square root and base conversion operations, and exponentiation when the exponent is
  38. * negative.
  39. *
  40. * ```ts
  41. * BigNumber.config({ DECIMAL_PLACES: 5 })
  42. * BigNumber.set({ DECIMAL_PLACES: 5 })
  43. * ```
  44. */
  45. DECIMAL_PLACES?: number;
  46. /**
  47. * An integer, 0 to 8. Default value: `BigNumber.ROUND_HALF_UP` (4).
  48. *
  49. * The rounding mode used in operations that involve division (see `DECIMAL_PLACES`) and the
  50. * default rounding mode of the `decimalPlaces`, `precision`, `toExponential`, `toFixed`,
  51. * `toFormat` and `toPrecision` methods.
  52. *
  53. * The modes are available as enumerated properties of the BigNumber constructor.
  54. *
  55. * ```ts
  56. * BigNumber.config({ ROUNDING_MODE: 0 })
  57. * BigNumber.set({ ROUNDING_MODE: BigNumber.ROUND_UP })
  58. * ```
  59. */
  60. ROUNDING_MODE?: BigNumber.RoundingMode;
  61. /**
  62. * An integer, 0 to 1e+9, or an array, [-1e+9 to 0, 0 to 1e+9].
  63. * Default value: `[-7, 20]`.
  64. *
  65. * The exponent value(s) at which `toString` returns exponential notation.
  66. *
  67. * If a single number is assigned, the value is the exponent magnitude.
  68. *
  69. * If an array of two numbers is assigned then the first number is the negative exponent value at
  70. * and beneath which exponential notation is used, and the second number is the positive exponent
  71. * value at and above which exponential notation is used.
  72. *
  73. * For example, to emulate JavaScript numbers in terms of the exponent values at which they begin
  74. * to use exponential notation, use `[-7, 20]`.
  75. *
  76. * ```ts
  77. * BigNumber.config({ EXPONENTIAL_AT: 2 })
  78. * new BigNumber(12.3) // '12.3' e is only 1
  79. * new BigNumber(123) // '1.23e+2'
  80. * new BigNumber(0.123) // '0.123' e is only -1
  81. * new BigNumber(0.0123) // '1.23e-2'
  82. *
  83. * BigNumber.config({ EXPONENTIAL_AT: [-7, 20] })
  84. * new BigNumber(123456789) // '123456789' e is only 8
  85. * new BigNumber(0.000000123) // '1.23e-7'
  86. *
  87. * // Almost never return exponential notation:
  88. * BigNumber.config({ EXPONENTIAL_AT: 1e+9 })
  89. *
  90. * // Always return exponential notation:
  91. * BigNumber.config({ EXPONENTIAL_AT: 0 })
  92. * ```
  93. *
  94. * Regardless of the value of `EXPONENTIAL_AT`, the `toFixed` method will always return a value in
  95. * normal notation and the `toExponential` method will always return a value in exponential form.
  96. * Calling `toString` with a base argument, e.g. `toString(10)`, will also always return normal
  97. * notation.
  98. */
  99. EXPONENTIAL_AT?: number | [number, number];
  100. /**
  101. * An integer, magnitude 1 to 1e+9, or an array, [-1e+9 to -1, 1 to 1e+9].
  102. * Default value: `[-1e+9, 1e+9]`.
  103. *
  104. * The exponent value(s) beyond which overflow to Infinity and underflow to zero occurs.
  105. *
  106. * If a single number is assigned, it is the maximum exponent magnitude: values wth a positive
  107. * exponent of greater magnitude become Infinity and those with a negative exponent of greater
  108. * magnitude become zero.
  109. *
  110. * If an array of two numbers is assigned then the first number is the negative exponent limit and
  111. * the second number is the positive exponent limit.
  112. *
  113. * For example, to emulate JavaScript numbers in terms of the exponent values at which they
  114. * become zero and Infinity, use [-324, 308].
  115. *
  116. * ```ts
  117. * BigNumber.config({ RANGE: 500 })
  118. * BigNumber.config().RANGE // [ -500, 500 ]
  119. * new BigNumber('9.999e499') // '9.999e+499'
  120. * new BigNumber('1e500') // 'Infinity'
  121. * new BigNumber('1e-499') // '1e-499'
  122. * new BigNumber('1e-500') // '0'
  123. *
  124. * BigNumber.config({ RANGE: [-3, 4] })
  125. * new BigNumber(99999) // '99999' e is only 4
  126. * new BigNumber(100000) // 'Infinity' e is 5
  127. * new BigNumber(0.001) // '0.01' e is only -3
  128. * new BigNumber(0.0001) // '0' e is -4
  129. * ```
  130. * The largest possible magnitude of a finite BigNumber is 9.999...e+1000000000.
  131. * The smallest possible magnitude of a non-zero BigNumber is 1e-1000000000.
  132. */
  133. RANGE?: number | [number, number];
  134. /**
  135. * A boolean: `true` or `false`. Default value: `false`.
  136. *
  137. * The value that determines whether cryptographically-secure pseudo-random number generation is
  138. * used. If `CRYPTO` is set to true then the random method will generate random digits using
  139. * `crypto.getRandomValues` in browsers that support it, or `crypto.randomBytes` if using a
  140. * version of Node.js that supports it.
  141. *
  142. * If neither function is supported by the host environment then attempting to set `CRYPTO` to
  143. * `true` will fail and an exception will be thrown.
  144. *
  145. * If `CRYPTO` is `false` then the source of randomness used will be `Math.random` (which is
  146. * assumed to generate at least 30 bits of randomness).
  147. *
  148. * See `BigNumber.random`.
  149. *
  150. * ```ts
  151. * // Node.js
  152. * global.crypto = require('crypto')
  153. *
  154. * BigNumber.config({ CRYPTO: true })
  155. * BigNumber.config().CRYPTO // true
  156. * BigNumber.random() // 0.54340758610486147524
  157. * ```
  158. */
  159. CRYPTO?: boolean;
  160. /**
  161. * An integer, 0, 1, 3, 6 or 9. Default value: `BigNumber.ROUND_DOWN` (1).
  162. *
  163. * The modulo mode used when calculating the modulus: `a mod n`.
  164. * The quotient, `q = a / n`, is calculated according to the `ROUNDING_MODE` that corresponds to
  165. * the chosen `MODULO_MODE`.
  166. * The remainder, `r`, is calculated as: `r = a - n * q`.
  167. *
  168. * The modes that are most commonly used for the modulus/remainder operation are shown in the
  169. * following table. Although the other rounding modes can be used, they may not give useful
  170. * results.
  171. *
  172. * Property | Value | Description
  173. * :------------------|:------|:------------------------------------------------------------------
  174. * `ROUND_UP` | 0 | The remainder is positive if the dividend is negative.
  175. * `ROUND_DOWN` | 1 | The remainder has the same sign as the dividend.
  176. * | | Uses 'truncating division' and matches JavaScript's `%` operator .
  177. * `ROUND_FLOOR` | 3 | The remainder has the same sign as the divisor.
  178. * | | This matches Python's `%` operator.
  179. * `ROUND_HALF_EVEN` | 6 | The IEEE 754 remainder function.
  180. * `EUCLID` | 9 | The remainder is always positive.
  181. * | | Euclidian division: `q = sign(n) * floor(a / abs(n))`
  182. *
  183. * The rounding/modulo modes are available as enumerated properties of the BigNumber constructor.
  184. *
  185. * See `modulo`.
  186. *
  187. * ```ts
  188. * BigNumber.config({ MODULO_MODE: BigNumber.EUCLID })
  189. * BigNumber.set({ MODULO_MODE: 9 }) // equivalent
  190. * ```
  191. */
  192. MODULO_MODE?: BigNumber.ModuloMode;
  193. /**
  194. * An integer, 0 to 1e+9. Default value: 0.
  195. *
  196. * The maximum precision, i.e. number of significant digits, of the result of the power operation
  197. * - unless a modulus is specified.
  198. *
  199. * If set to 0, the number of significant digits will not be limited.
  200. *
  201. * See `exponentiatedBy`.
  202. *
  203. * ```ts
  204. * BigNumber.config({ POW_PRECISION: 100 })
  205. * ```
  206. */
  207. POW_PRECISION?: number;
  208. /**
  209. * An object including any number of the properties shown below.
  210. *
  211. * The object configures the format of the string returned by the `toFormat` method.
  212. * The example below shows the properties of the object that are recognised, and
  213. * their default values.
  214. *
  215. * Unlike the other configuration properties, the values of the properties of the `FORMAT` object
  216. * will not be checked for validity - the existing object will simply be replaced by the object
  217. * that is passed in.
  218. *
  219. * See `toFormat`.
  220. *
  221. * ```ts
  222. * BigNumber.config({
  223. * FORMAT: {
  224. * // string to prepend
  225. * prefix: '',
  226. * // the decimal separator
  227. * decimalSeparator: '.',
  228. * // the grouping separator of the integer part
  229. * groupSeparator: ',',
  230. * // the primary grouping size of the integer part
  231. * groupSize: 3,
  232. * // the secondary grouping size of the integer part
  233. * secondaryGroupSize: 0,
  234. * // the grouping separator of the fraction part
  235. * fractionGroupSeparator: ' ',
  236. * // the grouping size of the fraction part
  237. * fractionGroupSize: 0,
  238. * // string to append
  239. * suffix: ''
  240. * }
  241. * })
  242. * ```
  243. */
  244. FORMAT?: BigNumber.Format;
  245. /**
  246. * The alphabet used for base conversion. The length of the alphabet corresponds to the maximum
  247. * value of the base argument that can be passed to the BigNumber constructor or `toString`.
  248. *
  249. * Default value: `'0123456789abcdefghijklmnopqrstuvwxyz'`.
  250. *
  251. * There is no maximum length for the alphabet, but it must be at least 2 characters long,
  252. * and it must not contain whitespace or a repeated character, or the sign indicators '+' and
  253. * '-', or the decimal separator '.'.
  254. *
  255. * ```ts
  256. * // duodecimal (base 12)
  257. * BigNumber.config({ ALPHABET: '0123456789TE' })
  258. * x = new BigNumber('T', 12)
  259. * x.toString() // '10'
  260. * x.toString(12) // 'T'
  261. * ```
  262. */
  263. ALPHABET?: string;
  264. }
  265. /** See `FORMAT` and `toFormat`. */
  266. interface Format {
  267. /** The string to prepend. */
  268. prefix?: string;
  269. /** The decimal separator. */
  270. decimalSeparator?: string;
  271. /** The grouping separator of the integer part. */
  272. groupSeparator?: string;
  273. /** The primary grouping size of the integer part. */
  274. groupSize?: number;
  275. /** The secondary grouping size of the integer part. */
  276. secondaryGroupSize?: number;
  277. /** The grouping separator of the fraction part. */
  278. fractionGroupSeparator?: string;
  279. /** The grouping size of the fraction part. */
  280. fractionGroupSize?: number;
  281. /** The string to append. */
  282. suffix?: string;
  283. }
  284. interface Instance {
  285. /** The coefficient of the value of this BigNumber, an array of base 1e14 integer numbers, or null. */
  286. readonly c: number[] | null;
  287. /** The exponent of the value of this BigNumber, an integer number, -1000000000 to 1000000000, or null. */
  288. readonly e: number | null;
  289. /** The sign of the value of this BigNumber, -1, 1, or null. */
  290. readonly s: number | null;
  291. [key: string]: any;
  292. }
  293. type Constructor = typeof BigNumber;
  294. type ModuloMode = 0 | 1 | 3 | 6 | 9;
  295. type RoundingMode = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8;
  296. type Value = string | number | bigint | Instance;
  297. }
  298. declare class BigNumber implements BigNumber.Instance {
  299. /** Used internally to identify a BigNumber instance. */
  300. private readonly _isBigNumber: true;
  301. /** The coefficient of the value of this BigNumber, an array of base 1e14 integer numbers, or null. */
  302. readonly c: number[] | null;
  303. /** The exponent of the value of this BigNumber, an integer number, -1000000000 to 1000000000, or null. */
  304. readonly e: number | null;
  305. /** The sign of the value of this BigNumber, -1, 1, or null. */
  306. readonly s: number | null;
  307. /**
  308. * Returns a new instance of a BigNumber object with value `n`, where `n` is a numeric value in
  309. * the specified `base`, or base 10 if `base` is omitted.
  310. *
  311. * ```ts
  312. * x = new BigNumber(123.4567) // '123.4567'
  313. * // 'new' is optional
  314. * y = BigNumber(x) // '123.4567'
  315. * ```
  316. *
  317. * If `n` is a base 10 value it can be in normal (fixed-point) or exponential notation.
  318. * Values in other bases must be in normal notation. Values in any base can have fraction digits,
  319. * i.e. digits after the decimal point.
  320. *
  321. * ```ts
  322. * new BigNumber(43210) // '43210'
  323. * new BigNumber('4.321e+4') // '43210'
  324. * new BigNumber('-735.0918e-430') // '-7.350918e-428'
  325. * new BigNumber('123412421.234324', 5) // '607236.557696'
  326. * ```
  327. *
  328. * Signed `0`, signed `Infinity` and `NaN` are supported.
  329. *
  330. * ```ts
  331. * new BigNumber('-Infinity') // '-Infinity'
  332. * new BigNumber(NaN) // 'NaN'
  333. * new BigNumber(-0) // '0'
  334. * new BigNumber('.5') // '0.5'
  335. * new BigNumber('+2') // '2'
  336. * ```
  337. *
  338. * String values in hexadecimal literal form, e.g. `'0xff'`, are valid, as are string values with
  339. * the octal and binary prefixs `'0o'` and `'0b'`. String values in octal literal form without the
  340. * prefix will be interpreted as decimals, e.g. `'011'` is interpreted as 11, not 9.
  341. *
  342. * ```ts
  343. * new BigNumber(-10110100.1, 2) // '-180.5'
  344. * new BigNumber('-0b10110100.1') // '-180.5'
  345. * new BigNumber('ff.8', 16) // '255.5'
  346. * new BigNumber('0xff.8') // '255.5'
  347. * ```
  348. *
  349. * If a base is specified, `n` is rounded according to the current `DECIMAL_PLACES` and
  350. * `ROUNDING_MODE` settings. This includes base 10, so don't include a `base` parameter for decimal
  351. * values unless this behaviour is desired.
  352. *
  353. * ```ts
  354. * BigNumber.config({ DECIMAL_PLACES: 5 })
  355. * new BigNumber(1.23456789) // '1.23456789'
  356. * new BigNumber(1.23456789, 10) // '1.23457'
  357. * ```
  358. *
  359. * An error is thrown if `base` is invalid.
  360. *
  361. * There is no limit to the number of digits of a value of type string (other than that of
  362. * JavaScript's maximum array size). See `RANGE` to set the maximum and minimum possible exponent
  363. * value of a BigNumber.
  364. *
  365. * ```ts
  366. * new BigNumber('5032485723458348569331745.33434346346912144534543')
  367. * new BigNumber('4.321e10000000')
  368. * ```
  369. *
  370. * BigNumber `NaN` is returned if `n` is invalid (unless `BigNumber.DEBUG` is `true`, see below).
  371. *
  372. * ```ts
  373. * new BigNumber('.1*') // 'NaN'
  374. * new BigNumber('blurgh') // 'NaN'
  375. * new BigNumber(9, 2) // 'NaN'
  376. * ```
  377. *
  378. * To aid in debugging, if `BigNumber.DEBUG` is `true` then an error will be thrown on an
  379. * invalid `n`. An error will also be thrown if `n` is of type number with more than 15
  380. * significant digits, as calling `toString` or `valueOf` on these numbers may not result in the
  381. * intended value.
  382. *
  383. * ```ts
  384. * console.log(823456789123456.3) // 823456789123456.2
  385. * new BigNumber(823456789123456.3) // '823456789123456.2'
  386. * BigNumber.DEBUG = true
  387. * // 'Error: Number has more than 15 significant digits'
  388. * new BigNumber(823456789123456.3)
  389. * // 'Error: Not a base 2 number'
  390. * new BigNumber(9, 2)
  391. * ```
  392. *
  393. * A BigNumber can also be created from an object literal.
  394. * Use `isBigNumber` to check that it is well-formed.
  395. *
  396. * ```ts
  397. * new BigNumber({ s: 1, e: 2, c: [ 777, 12300000000000 ], _isBigNumber: true }) // '777.123'
  398. * ```
  399. *
  400. * @param n A numeric value.
  401. * @param base The base of `n`, integer, 2 to 36 (or `ALPHABET.length`, see `ALPHABET`).
  402. */
  403. constructor(n: BigNumber.Value, base?: number);
  404. /**
  405. * Returns a BigNumber whose value is the absolute value, i.e. the magnitude, of the value of this
  406. * BigNumber.
  407. *
  408. * The return value is always exact and unrounded.
  409. *
  410. * ```ts
  411. * x = new BigNumber(-0.8)
  412. * x.absoluteValue() // '0.8'
  413. * ```
  414. */
  415. absoluteValue(): BigNumber;
  416. /**
  417. * Returns a BigNumber whose value is the absolute value, i.e. the magnitude, of the value of this
  418. * BigNumber.
  419. *
  420. * The return value is always exact and unrounded.
  421. *
  422. * ```ts
  423. * x = new BigNumber(-0.8)
  424. * x.abs() // '0.8'
  425. * ```
  426. */
  427. abs(): BigNumber;
  428. /**
  429. * Returns | |
  430. * :-------:|:--------------------------------------------------------------|
  431. * 1 | If the value of this BigNumber is greater than the value of `n`
  432. * -1 | If the value of this BigNumber is less than the value of `n`
  433. * 0 | If this BigNumber and `n` have the same value
  434. * `null` | If the value of either this BigNumber or `n` is `NaN`
  435. *
  436. * ```ts
  437. *
  438. * x = new BigNumber(Infinity)
  439. * y = new BigNumber(5)
  440. * x.comparedTo(y) // 1
  441. * x.comparedTo(x.minus(1)) // 0
  442. * y.comparedTo(NaN) // null
  443. * y.comparedTo('110', 2) // -1
  444. * ```
  445. * @param n A numeric value.
  446. * @param [base] The base of n.
  447. */
  448. comparedTo(n: BigNumber.Value, base?: number): 1 | -1 | 0 | null;
  449. /**
  450. * Returns a BigNumber whose value is the value of this BigNumber rounded by rounding mode
  451. * `roundingMode` to a maximum of `decimalPlaces` decimal places.
  452. *
  453. * If `decimalPlaces` is omitted, the return value is the number of decimal places of the value of
  454. * this BigNumber, or `null` if the value of this BigNumber is ±`Infinity` or `NaN`.
  455. *
  456. * If `roundingMode` is omitted, `ROUNDING_MODE` is used.
  457. *
  458. * Throws if `decimalPlaces` or `roundingMode` is invalid.
  459. *
  460. * ```ts
  461. * x = new BigNumber(1234.56)
  462. * x.decimalPlaces() // 2
  463. * x.decimalPlaces(1) // '1234.6'
  464. * x.decimalPlaces(2) // '1234.56'
  465. * x.decimalPlaces(10) // '1234.56'
  466. * x.decimalPlaces(0, 1) // '1234'
  467. * x.decimalPlaces(0, 6) // '1235'
  468. * x.decimalPlaces(1, 1) // '1234.5'
  469. * x.decimalPlaces(1, BigNumber.ROUND_HALF_EVEN) // '1234.6'
  470. * x // '1234.56'
  471. * y = new BigNumber('9.9e-101')
  472. * y.decimalPlaces() // 102
  473. * ```
  474. *
  475. * @param [decimalPlaces] Decimal places, integer, 0 to 1e+9.
  476. * @param [roundingMode] Rounding mode, integer, 0 to 8.
  477. */
  478. decimalPlaces(): number | null;
  479. decimalPlaces(decimalPlaces: number, roundingMode?: BigNumber.RoundingMode): BigNumber;
  480. /**
  481. * Returns a BigNumber whose value is the value of this BigNumber rounded by rounding mode
  482. * `roundingMode` to a maximum of `decimalPlaces` decimal places.
  483. *
  484. * If `decimalPlaces` is omitted, the return value is the number of decimal places of the value of
  485. * this BigNumber, or `null` if the value of this BigNumber is ±`Infinity` or `NaN`.
  486. *
  487. * If `roundingMode` is omitted, `ROUNDING_MODE` is used.
  488. *
  489. * Throws if `decimalPlaces` or `roundingMode` is invalid.
  490. *
  491. * ```ts
  492. * x = new BigNumber(1234.56)
  493. * x.dp() // 2
  494. * x.dp(1) // '1234.6'
  495. * x.dp(2) // '1234.56'
  496. * x.dp(10) // '1234.56'
  497. * x.dp(0, 1) // '1234'
  498. * x.dp(0, 6) // '1235'
  499. * x.dp(1, 1) // '1234.5'
  500. * x.dp(1, BigNumber.ROUND_HALF_EVEN) // '1234.6'
  501. * x // '1234.56'
  502. * y = new BigNumber('9.9e-101')
  503. * y.dp() // 102
  504. * ```
  505. *
  506. * @param [decimalPlaces] Decimal places, integer, 0 to 1e+9.
  507. * @param [roundingMode] Rounding mode, integer, 0 to 8.
  508. */
  509. dp(): number | null;
  510. dp(decimalPlaces: number, roundingMode?: BigNumber.RoundingMode): BigNumber;
  511. /**
  512. * Returns a BigNumber whose value is the value of this BigNumber divided by `n`, rounded
  513. * according to the current `DECIMAL_PLACES` and `ROUNDING_MODE` settings.
  514. *
  515. * ```ts
  516. * x = new BigNumber(355)
  517. * y = new BigNumber(113)
  518. * x.dividedBy(y) // '3.14159292035398230088'
  519. * x.dividedBy(5) // '71'
  520. * x.dividedBy(47, 16) // '5'
  521. * ```
  522. *
  523. * @param n A numeric value.
  524. * @param [base] The base of n.
  525. */
  526. dividedBy(n: BigNumber.Value, base?: number): BigNumber;
  527. /**
  528. * Returns a BigNumber whose value is the value of this BigNumber divided by `n`, rounded
  529. * according to the current `DECIMAL_PLACES` and `ROUNDING_MODE` settings.
  530. *
  531. * ```ts
  532. * x = new BigNumber(355)
  533. * y = new BigNumber(113)
  534. * x.div(y) // '3.14159292035398230088'
  535. * x.div(5) // '71'
  536. * x.div(47, 16) // '5'
  537. * ```
  538. *
  539. * @param n A numeric value.
  540. * @param [base] The base of n.
  541. */
  542. div(n: BigNumber.Value, base?: number): BigNumber;
  543. /**
  544. * Returns a BigNumber whose value is the integer part of dividing the value of this BigNumber by
  545. * `n`.
  546. *
  547. * ```ts
  548. * x = new BigNumber(5)
  549. * y = new BigNumber(3)
  550. * x.dividedToIntegerBy(y) // '1'
  551. * x.dividedToIntegerBy(0.7) // '7'
  552. * x.dividedToIntegerBy('0.f', 16) // '5'
  553. * ```
  554. *
  555. * @param n A numeric value.
  556. * @param [base] The base of n.
  557. */
  558. dividedToIntegerBy(n: BigNumber.Value, base?: number): BigNumber;
  559. /**
  560. * Returns a BigNumber whose value is the integer part of dividing the value of this BigNumber by
  561. * `n`.
  562. *
  563. * ```ts
  564. * x = new BigNumber(5)
  565. * y = new BigNumber(3)
  566. * x.idiv(y) // '1'
  567. * x.idiv(0.7) // '7'
  568. * x.idiv('0.f', 16) // '5'
  569. * ```
  570. *
  571. * @param n A numeric value.
  572. * @param [base] The base of n.
  573. */
  574. idiv(n: BigNumber.Value, base?: number): BigNumber;
  575. /**
  576. * Returns a BigNumber whose value is the value of this BigNumber exponentiated by `n`, i.e.
  577. * raised to the power `n`, and optionally modulo a modulus `m`.
  578. *
  579. * If `n` is negative the result is rounded according to the current `DECIMAL_PLACES` and
  580. * `ROUNDING_MODE` settings.
  581. *
  582. * As the number of digits of the result of the power operation can grow so large so quickly,
  583. * e.g. 123.456**10000 has over 50000 digits, the number of significant digits calculated is
  584. * limited to the value of the `POW_PRECISION` setting (unless a modulus `m` is specified).
  585. *
  586. * By default `POW_PRECISION` is set to 0. This means that an unlimited number of significant
  587. * digits will be calculated, and that the method's performance will decrease dramatically for
  588. * larger exponents.
  589. *
  590. * If `m` is specified and the value of `m`, `n` and this BigNumber are integers and `n` is
  591. * positive, then a fast modular exponentiation algorithm is used, otherwise the operation will
  592. * be performed as `x.exponentiatedBy(n).modulo(m)` with a `POW_PRECISION` of 0.
  593. *
  594. * Throws if `n` is not an integer.
  595. *
  596. * ```ts
  597. * Math.pow(0.7, 2) // 0.48999999999999994
  598. * x = new BigNumber(0.7)
  599. * x.exponentiatedBy(2) // '0.49'
  600. * BigNumber(3).exponentiatedBy(-2) // '0.11111111111111111111'
  601. * ```
  602. *
  603. * @param n The exponent, an integer.
  604. * @param [m] The modulus.
  605. */
  606. exponentiatedBy(n: BigNumber.Value, m?: BigNumber.Value): BigNumber;
  607. exponentiatedBy(n: number, m?: BigNumber.Value): BigNumber;
  608. /**
  609. * Returns a BigNumber whose value is the value of this BigNumber exponentiated by `n`, i.e.
  610. * raised to the power `n`, and optionally modulo a modulus `m`.
  611. *
  612. * If `n` is negative the result is rounded according to the current `DECIMAL_PLACES` and
  613. * `ROUNDING_MODE` settings.
  614. *
  615. * As the number of digits of the result of the power operation can grow so large so quickly,
  616. * e.g. 123.456**10000 has over 50000 digits, the number of significant digits calculated is
  617. * limited to the value of the `POW_PRECISION` setting (unless a modulus `m` is specified).
  618. *
  619. * By default `POW_PRECISION` is set to 0. This means that an unlimited number of significant
  620. * digits will be calculated, and that the method's performance will decrease dramatically for
  621. * larger exponents.
  622. *
  623. * If `m` is specified and the value of `m`, `n` and this BigNumber are integers and `n` is
  624. * positive, then a fast modular exponentiation algorithm is used, otherwise the operation will
  625. * be performed as `x.pow(n).modulo(m)` with a `POW_PRECISION` of 0.
  626. *
  627. * Throws if `n` is not an integer.
  628. *
  629. * ```ts
  630. * Math.pow(0.7, 2) // 0.48999999999999994
  631. * x = new BigNumber(0.7)
  632. * x.pow(2) // '0.49'
  633. * BigNumber(3).pow(-2) // '0.11111111111111111111'
  634. * ```
  635. *
  636. * @param n The exponent, an integer.
  637. * @param [m] The modulus.
  638. */
  639. pow(n: BigNumber.Value, m?: BigNumber.Value): BigNumber;
  640. pow(n: number, m?: BigNumber.Value): BigNumber;
  641. /**
  642. * Returns a BigNumber whose value is the value of this BigNumber rounded to an integer using
  643. * rounding mode `rm`.
  644. *
  645. * If `rm` is omitted, `ROUNDING_MODE` is used.
  646. *
  647. * Throws if `rm` is invalid.
  648. *
  649. * ```ts
  650. * x = new BigNumber(123.456)
  651. * x.integerValue() // '123'
  652. * x.integerValue(BigNumber.ROUND_CEIL) // '124'
  653. * y = new BigNumber(-12.7)
  654. * y.integerValue() // '-13'
  655. * x.integerValue(BigNumber.ROUND_DOWN) // '-12'
  656. * ```
  657. *
  658. * @param {BigNumber.RoundingMode} [rm] The roundng mode, an integer, 0 to 8.
  659. */
  660. integerValue(rm?: BigNumber.RoundingMode): BigNumber;
  661. /**
  662. * Returns `true` if the value of this BigNumber is equal to the value of `n`, otherwise returns
  663. * `false`.
  664. *
  665. * As with JavaScript, `NaN` does not equal `NaN`.
  666. *
  667. * ```ts
  668. * 0 === 1e-324 // true
  669. * x = new BigNumber(0)
  670. * x.isEqualTo('1e-324') // false
  671. * BigNumber(-0).isEqualTo(x) // true ( -0 === 0 )
  672. * BigNumber(255).isEqualTo('ff', 16) // true
  673. *
  674. * y = new BigNumber(NaN)
  675. * y.isEqualTo(NaN) // false
  676. * ```
  677. *
  678. * @param n A numeric value.
  679. * @param [base] The base of n.
  680. */
  681. isEqualTo(n: BigNumber.Value, base?: number): boolean;
  682. /**
  683. * Returns `true` if the value of this BigNumber is equal to the value of `n`, otherwise returns
  684. * `false`.
  685. *
  686. * As with JavaScript, `NaN` does not equal `NaN`.
  687. *
  688. * ```ts
  689. * 0 === 1e-324 // true
  690. * x = new BigNumber(0)
  691. * x.eq('1e-324') // false
  692. * BigNumber(-0).eq(x) // true ( -0 === 0 )
  693. * BigNumber(255).eq('ff', 16) // true
  694. *
  695. * y = new BigNumber(NaN)
  696. * y.eq(NaN) // false
  697. * ```
  698. *
  699. * @param n A numeric value.
  700. * @param [base] The base of n.
  701. */
  702. eq(n: BigNumber.Value, base?: number): boolean;
  703. /**
  704. * Returns `true` if the value of this BigNumber is a finite number, otherwise returns `false`.
  705. *
  706. * The only possible non-finite values of a BigNumber are `NaN`, `Infinity` and `-Infinity`.
  707. *
  708. * ```ts
  709. * x = new BigNumber(1)
  710. * x.isFinite() // true
  711. * y = new BigNumber(Infinity)
  712. * y.isFinite() // false
  713. * ```
  714. */
  715. isFinite(): boolean;
  716. /**
  717. * Returns `true` if the value of this BigNumber is greater than the value of `n`, otherwise
  718. * returns `false`.
  719. *
  720. * ```ts
  721. * 0.1 > (0.3 - 0.2) // true
  722. * x = new BigNumber(0.1)
  723. * x.isGreaterThan(BigNumber(0.3).minus(0.2)) // false
  724. * BigNumber(0).isGreaterThan(x) // false
  725. * BigNumber(11, 3).isGreaterThan(11.1, 2) // true
  726. * ```
  727. *
  728. * @param n A numeric value.
  729. * @param [base] The base of n.
  730. */
  731. isGreaterThan(n: BigNumber.Value, base?: number): boolean;
  732. /**
  733. * Returns `true` if the value of this BigNumber is greater than the value of `n`, otherwise
  734. * returns `false`.
  735. *
  736. * ```ts
  737. * 0.1 > (0.3 - 0.2) // true
  738. * x = new BigNumber(0.1)
  739. * x.gt(BigNumber(0.3).minus(0.2)) // false
  740. * BigNumber(0).gt(x) // false
  741. * BigNumber(11, 3).gt(11.1, 2) // true
  742. * ```
  743. *
  744. * @param n A numeric value.
  745. * @param [base] The base of n.
  746. */
  747. gt(n: BigNumber.Value, base?: number): boolean;
  748. /**
  749. * Returns `true` if the value of this BigNumber is greater than or equal to the value of `n`,
  750. * otherwise returns `false`.
  751. *
  752. * ```ts
  753. * (0.3 - 0.2) >= 0.1 // false
  754. * x = new BigNumber(0.3).minus(0.2)
  755. * x.isGreaterThanOrEqualTo(0.1) // true
  756. * BigNumber(1).isGreaterThanOrEqualTo(x) // true
  757. * BigNumber(10, 18).isGreaterThanOrEqualTo('i', 36) // true
  758. * ```
  759. *
  760. * @param n A numeric value.
  761. * @param [base] The base of n.
  762. */
  763. isGreaterThanOrEqualTo(n: BigNumber.Value, base?: number): boolean;
  764. /**
  765. * Returns `true` if the value of this BigNumber is greater than or equal to the value of `n`,
  766. * otherwise returns `false`.
  767. *
  768. * ```ts
  769. * (0.3 - 0.2) >= 0.1 // false
  770. * x = new BigNumber(0.3).minus(0.2)
  771. * x.gte(0.1) // true
  772. * BigNumber(1).gte(x) // true
  773. * BigNumber(10, 18).gte('i', 36) // true
  774. * ```
  775. *
  776. * @param n A numeric value.
  777. * @param [base] The base of n.
  778. */
  779. gte(n: BigNumber.Value, base?: number): boolean;
  780. /**
  781. * Returns `true` if the value of this BigNumber is an integer, otherwise returns `false`.
  782. *
  783. * ```ts
  784. * x = new BigNumber(1)
  785. * x.isInteger() // true
  786. * y = new BigNumber(123.456)
  787. * y.isInteger() // false
  788. * ```
  789. */
  790. isInteger(): boolean;
  791. /**
  792. * Returns `true` if the value of this BigNumber is less than the value of `n`, otherwise returns
  793. * `false`.
  794. *
  795. * ```ts
  796. * (0.3 - 0.2) < 0.1 // true
  797. * x = new BigNumber(0.3).minus(0.2)
  798. * x.isLessThan(0.1) // false
  799. * BigNumber(0).isLessThan(x) // true
  800. * BigNumber(11.1, 2).isLessThan(11, 3) // true
  801. * ```
  802. *
  803. * @param n A numeric value.
  804. * @param [base] The base of n.
  805. */
  806. isLessThan(n: BigNumber.Value, base?: number): boolean;
  807. /**
  808. * Returns `true` if the value of this BigNumber is less than the value of `n`, otherwise returns
  809. * `false`.
  810. *
  811. * ```ts
  812. * (0.3 - 0.2) < 0.1 // true
  813. * x = new BigNumber(0.3).minus(0.2)
  814. * x.lt(0.1) // false
  815. * BigNumber(0).lt(x) // true
  816. * BigNumber(11.1, 2).lt(11, 3) // true
  817. * ```
  818. *
  819. * @param n A numeric value.
  820. * @param [base] The base of n.
  821. */
  822. lt(n: BigNumber.Value, base?: number): boolean;
  823. /**
  824. * Returns `true` if the value of this BigNumber is less than or equal to the value of `n`,
  825. * otherwise returns `false`.
  826. *
  827. * ```ts
  828. * 0.1 <= (0.3 - 0.2) // false
  829. * x = new BigNumber(0.1)
  830. * x.isLessThanOrEqualTo(BigNumber(0.3).minus(0.2)) // true
  831. * BigNumber(-1).isLessThanOrEqualTo(x) // true
  832. * BigNumber(10, 18).isLessThanOrEqualTo('i', 36) // true
  833. * ```
  834. *
  835. * @param n A numeric value.
  836. * @param [base] The base of n.
  837. */
  838. isLessThanOrEqualTo(n: BigNumber.Value, base?: number): boolean;
  839. /**
  840. * Returns `true` if the value of this BigNumber is less than or equal to the value of `n`,
  841. * otherwise returns `false`.
  842. *
  843. * ```ts
  844. * 0.1 <= (0.3 - 0.2) // false
  845. * x = new BigNumber(0.1)
  846. * x.lte(BigNumber(0.3).minus(0.2)) // true
  847. * BigNumber(-1).lte(x) // true
  848. * BigNumber(10, 18).lte('i', 36) // true
  849. * ```
  850. *
  851. * @param n A numeric value.
  852. * @param [base] The base of n.
  853. */
  854. lte(n: BigNumber.Value, base?: number): boolean;
  855. /**
  856. * Returns `true` if the value of this BigNumber is `NaN`, otherwise returns `false`.
  857. *
  858. * ```ts
  859. * x = new BigNumber(NaN)
  860. * x.isNaN() // true
  861. * y = new BigNumber('Infinity')
  862. * y.isNaN() // false
  863. * ```
  864. */
  865. isNaN(): boolean;
  866. /**
  867. * Returns `true` if the value of this BigNumber is negative, otherwise returns `false`.
  868. *
  869. * ```ts
  870. * x = new BigNumber(-0)
  871. * x.isNegative() // true
  872. * y = new BigNumber(2)
  873. * y.isNegative() // false
  874. * ```
  875. */
  876. isNegative(): boolean;
  877. /**
  878. * Returns `true` if the value of this BigNumber is positive, otherwise returns `false`.
  879. *
  880. * ```ts
  881. * x = new BigNumber(-0)
  882. * x.isPositive() // false
  883. * y = new BigNumber(2)
  884. * y.isPositive() // true
  885. * ```
  886. */
  887. isPositive(): boolean;
  888. /**
  889. * Returns `true` if the value of this BigNumber is zero or minus zero, otherwise returns `false`.
  890. *
  891. * ```ts
  892. * x = new BigNumber(-0)
  893. * x.isZero() // true
  894. * ```
  895. */
  896. isZero(): boolean;
  897. /**
  898. * Returns a BigNumber whose value is the value of this BigNumber minus `n`.
  899. *
  900. * The return value is always exact and unrounded.
  901. *
  902. * ```ts
  903. * 0.3 - 0.1 // 0.19999999999999998
  904. * x = new BigNumber(0.3)
  905. * x.minus(0.1) // '0.2'
  906. * x.minus(0.6, 20) // '0'
  907. * ```
  908. *
  909. * @param n A numeric value.
  910. * @param [base] The base of n.
  911. */
  912. minus(n: BigNumber.Value, base?: number): BigNumber;
  913. /**
  914. * Returns a BigNumber whose value is the value of this BigNumber modulo `n`, i.e. the integer
  915. * remainder of dividing this BigNumber by `n`.
  916. *
  917. * The value returned, and in particular its sign, is dependent on the value of the `MODULO_MODE`
  918. * setting of this BigNumber constructor. If it is 1 (default value), the result will have the
  919. * same sign as this BigNumber, and it will match that of Javascript's `%` operator (within the
  920. * limits of double precision) and BigDecimal's `remainder` method.
  921. *
  922. * The return value is always exact and unrounded.
  923. *
  924. * See `MODULO_MODE` for a description of the other modulo modes.
  925. *
  926. * ```ts
  927. * 1 % 0.9 // 0.09999999999999998
  928. * x = new BigNumber(1)
  929. * x.modulo(0.9) // '0.1'
  930. * y = new BigNumber(33)
  931. * y.modulo('a', 33) // '3'
  932. * ```
  933. *
  934. * @param n A numeric value.
  935. * @param [base] The base of n.
  936. */
  937. modulo(n: BigNumber.Value, base?: number): BigNumber;
  938. /**
  939. * Returns a BigNumber whose value is the value of this BigNumber modulo `n`, i.e. the integer
  940. * remainder of dividing this BigNumber by `n`.
  941. *
  942. * The value returned, and in particular its sign, is dependent on the value of the `MODULO_MODE`
  943. * setting of this BigNumber constructor. If it is 1 (default value), the result will have the
  944. * same sign as this BigNumber, and it will match that of Javascript's `%` operator (within the
  945. * limits of double precision) and BigDecimal's `remainder` method.
  946. *
  947. * The return value is always exact and unrounded.
  948. *
  949. * See `MODULO_MODE` for a description of the other modulo modes.
  950. *
  951. * ```ts
  952. * 1 % 0.9 // 0.09999999999999998
  953. * x = new BigNumber(1)
  954. * x.mod(0.9) // '0.1'
  955. * y = new BigNumber(33)
  956. * y.mod('a', 33) // '3'
  957. * ```
  958. *
  959. * @param n A numeric value.
  960. * @param [base] The base of n.
  961. */
  962. mod(n: BigNumber.Value, base?: number): BigNumber;
  963. /**
  964. * Returns a BigNumber whose value is the value of this BigNumber multiplied by `n`.
  965. *
  966. * The return value is always exact and unrounded.
  967. *
  968. * ```ts
  969. * 0.6 * 3 // 1.7999999999999998
  970. * x = new BigNumber(0.6)
  971. * y = x.multipliedBy(3) // '1.8'
  972. * BigNumber('7e+500').multipliedBy(y) // '1.26e+501'
  973. * x.multipliedBy('-a', 16) // '-6'
  974. * ```
  975. *
  976. * @param n A numeric value.
  977. * @param [base] The base of n.
  978. */
  979. multipliedBy(n: BigNumber.Value, base?: number): BigNumber;
  980. /**
  981. * Returns a BigNumber whose value is the value of this BigNumber multiplied by `n`.
  982. *
  983. * The return value is always exact and unrounded.
  984. *
  985. * ```ts
  986. * 0.6 * 3 // 1.7999999999999998
  987. * x = new BigNumber(0.6)
  988. * y = x.times(3) // '1.8'
  989. * BigNumber('7e+500').times(y) // '1.26e+501'
  990. * x.times('-a', 16) // '-6'
  991. * ```
  992. *
  993. * @param n A numeric value.
  994. * @param [base] The base of n.
  995. */
  996. times(n: BigNumber.Value, base?: number): BigNumber;
  997. /**
  998. * Returns a BigNumber whose value is the value of this BigNumber negated, i.e. multiplied by -1.
  999. *
  1000. * ```ts
  1001. * x = new BigNumber(1.8)
  1002. * x.negated() // '-1.8'
  1003. * y = new BigNumber(-1.3)
  1004. * y.negated() // '1.3'
  1005. * ```
  1006. */
  1007. negated(): BigNumber;
  1008. /**
  1009. * Returns a BigNumber whose value is the value of this BigNumber plus `n`.
  1010. *
  1011. * The return value is always exact and unrounded.
  1012. *
  1013. * ```ts
  1014. * 0.1 + 0.2 // 0.30000000000000004
  1015. * x = new BigNumber(0.1)
  1016. * y = x.plus(0.2) // '0.3'
  1017. * BigNumber(0.7).plus(x).plus(y) // '1.1'
  1018. * x.plus('0.1', 8) // '0.225'
  1019. * ```
  1020. *
  1021. * @param n A numeric value.
  1022. * @param [base] The base of n.
  1023. */
  1024. plus(n: BigNumber.Value, base?: number): BigNumber;
  1025. /**
  1026. * Returns the number of significant digits of the value of this BigNumber, or `null` if the value
  1027. * of this BigNumber is ±`Infinity` or `NaN`.
  1028. *
  1029. * If `includeZeros` is true then any trailing zeros of the integer part of the value of this
  1030. * BigNumber are counted as significant digits, otherwise they are not.
  1031. *
  1032. * Throws if `includeZeros` is invalid.
  1033. *
  1034. * ```ts
  1035. * x = new BigNumber(9876.54321)
  1036. * x.precision() // 9
  1037. * y = new BigNumber(987000)
  1038. * y.precision(false) // 3
  1039. * y.precision(true) // 6
  1040. * ```
  1041. *
  1042. * @param [includeZeros] Whether to include integer trailing zeros in the significant digit count.
  1043. */
  1044. precision(includeZeros?: boolean): number;
  1045. /**
  1046. * Returns a BigNumber whose value is the value of this BigNumber rounded to a precision of
  1047. * `significantDigits` significant digits using rounding mode `roundingMode`.
  1048. *
  1049. * If `roundingMode` is omitted, `ROUNDING_MODE` will be used.
  1050. *
  1051. * Throws if `significantDigits` or `roundingMode` is invalid.
  1052. *
  1053. * ```ts
  1054. * x = new BigNumber(9876.54321)
  1055. * x.precision(6) // '9876.54'
  1056. * x.precision(6, BigNumber.ROUND_UP) // '9876.55'
  1057. * x.precision(2) // '9900'
  1058. * x.precision(2, 1) // '9800'
  1059. * x // '9876.54321'
  1060. * ```
  1061. *
  1062. * @param significantDigits Significant digits, integer, 1 to 1e+9.
  1063. * @param [roundingMode] Rounding mode, integer, 0 to 8.
  1064. */
  1065. precision(significantDigits: number, roundingMode?: BigNumber.RoundingMode): BigNumber;
  1066. /**
  1067. * Returns the number of significant digits of the value of this BigNumber,
  1068. * or `null` if the value of this BigNumber is ±`Infinity` or `NaN`.
  1069. *
  1070. * If `includeZeros` is true then any trailing zeros of the integer part of
  1071. * the value of this BigNumber are counted as significant digits, otherwise
  1072. * they are not.
  1073. *
  1074. * Throws if `includeZeros` is invalid.
  1075. *
  1076. * ```ts
  1077. * x = new BigNumber(9876.54321)
  1078. * x.sd() // 9
  1079. * y = new BigNumber(987000)
  1080. * y.sd(false) // 3
  1081. * y.sd(true) // 6
  1082. * ```
  1083. *
  1084. * @param [includeZeros] Whether to include integer trailing zeros in the significant digit count.
  1085. */
  1086. sd(includeZeros?: boolean): number;
  1087. /**
  1088. * Returns a BigNumber whose value is the value of this BigNumber rounded to a precision of
  1089. * `significantDigits` significant digits using rounding mode `roundingMode`.
  1090. *
  1091. * If `roundingMode` is omitted, `ROUNDING_MODE` will be used.
  1092. *
  1093. * Throws if `significantDigits` or `roundingMode` is invalid.
  1094. *
  1095. * ```ts
  1096. * x = new BigNumber(9876.54321)
  1097. * x.sd(6) // '9876.54'
  1098. * x.sd(6, BigNumber.ROUND_UP) // '9876.55'
  1099. * x.sd(2) // '9900'
  1100. * x.sd(2, 1) // '9800'
  1101. * x // '9876.54321'
  1102. * ```
  1103. *
  1104. * @param significantDigits Significant digits, integer, 1 to 1e+9.
  1105. * @param [roundingMode] Rounding mode, integer, 0 to 8.
  1106. */
  1107. sd(significantDigits: number, roundingMode?: BigNumber.RoundingMode): BigNumber;
  1108. /**
  1109. * Returns a BigNumber whose value is the value of this BigNumber shifted by `n` places.
  1110. *
  1111. * The shift is of the decimal point, i.e. of powers of ten, and is to the left if `n` is negative
  1112. * or to the right if `n` is positive.
  1113. *
  1114. * The return value is always exact and unrounded.
  1115. *
  1116. * Throws if `n` is invalid.
  1117. *
  1118. * ```ts
  1119. * x = new BigNumber(1.23)
  1120. * x.shiftedBy(3) // '1230'
  1121. * x.shiftedBy(-3) // '0.00123'
  1122. * ```
  1123. *
  1124. * @param n The shift value, integer, -9007199254740991 to 9007199254740991.
  1125. */
  1126. shiftedBy(n: number): BigNumber;
  1127. /**
  1128. * Returns a BigNumber whose value is the square root of the value of this BigNumber, rounded
  1129. * according to the current `DECIMAL_PLACES` and `ROUNDING_MODE` settings.
  1130. *
  1131. * The return value will be correctly rounded, i.e. rounded as if the result was first calculated
  1132. * to an infinite number of correct digits before rounding.
  1133. *
  1134. * ```ts
  1135. * x = new BigNumber(16)
  1136. * x.squareRoot() // '4'
  1137. * y = new BigNumber(3)
  1138. * y.squareRoot() // '1.73205080756887729353'
  1139. * ```
  1140. */
  1141. squareRoot(): BigNumber;
  1142. /**
  1143. * Returns a BigNumber whose value is the square root of the value of this BigNumber, rounded
  1144. * according to the current `DECIMAL_PLACES` and `ROUNDING_MODE` settings.
  1145. *
  1146. * The return value will be correctly rounded, i.e. rounded as if the result was first calculated
  1147. * to an infinite number of correct digits before rounding.
  1148. *
  1149. * ```ts
  1150. * x = new BigNumber(16)
  1151. * x.sqrt() // '4'
  1152. * y = new BigNumber(3)
  1153. * y.sqrt() // '1.73205080756887729353'
  1154. * ```
  1155. */
  1156. sqrt(): BigNumber;
  1157. /**
  1158. * Returns a string representing the value of this BigNumber in exponential notation rounded using
  1159. * rounding mode `roundingMode` to `decimalPlaces` decimal places, i.e with one digit before the
  1160. * decimal point and `decimalPlaces` digits after it.
  1161. *
  1162. * If the value of this BigNumber in exponential notation has fewer than `decimalPlaces` fraction
  1163. * digits, the return value will be appended with zeros accordingly.
  1164. *
  1165. * If `decimalPlaces` is omitted, the number of digits after the decimal point defaults to the
  1166. * minimum number of digits necessary to represent the value exactly.
  1167. *
  1168. * If `roundingMode` is omitted, `ROUNDING_MODE` is used.
  1169. *
  1170. * Throws if `decimalPlaces` or `roundingMode` is invalid.
  1171. *
  1172. * ```ts
  1173. * x = 45.6
  1174. * y = new BigNumber(x)
  1175. * x.toExponential() // '4.56e+1'
  1176. * y.toExponential() // '4.56e+1'
  1177. * x.toExponential(0) // '5e+1'
  1178. * y.toExponential(0) // '5e+1'
  1179. * x.toExponential(1) // '4.6e+1'
  1180. * y.toExponential(1) // '4.6e+1'
  1181. * y.toExponential(1, 1) // '4.5e+1' (ROUND_DOWN)
  1182. * x.toExponential(3) // '4.560e+1'
  1183. * y.toExponential(3) // '4.560e+1'
  1184. * ```
  1185. *
  1186. * @param [decimalPlaces] Decimal places, integer, 0 to 1e+9.
  1187. * @param [roundingMode] Rounding mode, integer, 0 to 8.
  1188. */
  1189. toExponential(decimalPlaces: number, roundingMode?: BigNumber.RoundingMode): string;
  1190. toExponential(): string;
  1191. /**
  1192. * Returns a string representing the value of this BigNumber in normal (fixed-point) notation
  1193. * rounded to `decimalPlaces` decimal places using rounding mode `roundingMode`.
  1194. *
  1195. * If the value of this BigNumber in normal notation has fewer than `decimalPlaces` fraction
  1196. * digits, the return value will be appended with zeros accordingly.
  1197. *
  1198. * Unlike `Number.prototype.toFixed`, which returns exponential notation if a number is greater or
  1199. * equal to 10**21, this method will always return normal notation.
  1200. *
  1201. * If `decimalPlaces` is omitted, the return value will be unrounded and in normal notation.
  1202. * This is also unlike `Number.prototype.toFixed`, which returns the value to zero decimal places.
  1203. * It is useful when normal notation is required and the current `EXPONENTIAL_AT` setting causes
  1204. * `toString` to return exponential notation.
  1205. *
  1206. * If `roundingMode` is omitted, `ROUNDING_MODE` is used.
  1207. *
  1208. * Throws if `decimalPlaces` or `roundingMode` is invalid.
  1209. *
  1210. * ```ts
  1211. * x = 3.456
  1212. * y = new BigNumber(x)
  1213. * x.toFixed() // '3'
  1214. * y.toFixed() // '3.456'
  1215. * y.toFixed(0) // '3'
  1216. * x.toFixed(2) // '3.46'
  1217. * y.toFixed(2) // '3.46'
  1218. * y.toFixed(2, 1) // '3.45' (ROUND_DOWN)
  1219. * x.toFixed(5) // '3.45600'
  1220. * y.toFixed(5) // '3.45600'
  1221. * ```
  1222. *
  1223. * @param [decimalPlaces] Decimal places, integer, 0 to 1e+9.
  1224. * @param [roundingMode] Rounding mode, integer, 0 to 8.
  1225. */
  1226. toFixed(decimalPlaces: number, roundingMode?: BigNumber.RoundingMode): string;
  1227. toFixed(): string;
  1228. /**
  1229. * Returns a string representing the value of this BigNumber in normal (fixed-point) notation
  1230. * rounded to `decimalPlaces` decimal places using rounding mode `roundingMode`, and formatted
  1231. * according to the properties of the `format` or `FORMAT` object.
  1232. *
  1233. * The formatting object may contain some or all of the properties shown in the examples below.
  1234. *
  1235. * If `decimalPlaces` is omitted, then the return value is not rounded to a fixed number of
  1236. * decimal places.
  1237. *
  1238. * If `roundingMode` is omitted, `ROUNDING_MODE` is used.
  1239. *
  1240. * If `format` is omitted, `FORMAT` is used.
  1241. *
  1242. * Throws if `decimalPlaces`, `roundingMode`, or `format` is invalid.
  1243. *
  1244. * ```ts
  1245. * fmt = {
  1246. * decimalSeparator: '.',
  1247. * groupSeparator: ',',
  1248. * groupSize: 3,
  1249. * secondaryGroupSize: 0,
  1250. * fractionGroupSeparator: ' ',
  1251. * fractionGroupSize: 0
  1252. * }
  1253. *
  1254. * x = new BigNumber('123456789.123456789')
  1255. *
  1256. * // Set the global formatting options
  1257. * BigNumber.config({ FORMAT: fmt })
  1258. *
  1259. * x.toFormat() // '123,456,789.123456789'
  1260. * x.toFormat(3) // '123,456,789.123'
  1261. *
  1262. * // If a reference to the object assigned to FORMAT has been retained,
  1263. * // the format properties can be changed directly
  1264. * fmt.groupSeparator = ' '
  1265. * fmt.fractionGroupSize = 5
  1266. * x.toFormat() // '123 456 789.12345 6789'
  1267. *
  1268. * // Alternatively, pass the formatting options as an argument
  1269. * fmt = {
  1270. * decimalSeparator: ',',
  1271. * groupSeparator: '.',
  1272. * groupSize: 3,
  1273. * secondaryGroupSize: 2
  1274. * }
  1275. *
  1276. * x.toFormat() // '123 456 789.12345 6789'
  1277. * x.toFormat(fmt) // '12.34.56.789,123456789'
  1278. * x.toFormat(2, fmt) // '12.34.56.789,12'
  1279. * x.toFormat(3, BigNumber.ROUND_UP, fmt) // '12.34.56.789,124'
  1280. * ```
  1281. *
  1282. * @param [decimalPlaces] Decimal places, integer, 0 to 1e+9.
  1283. * @param [roundingMode] Rounding mode, integer, 0 to 8.
  1284. * @param [format] Formatting options object. See `BigNumber.Format`.
  1285. */
  1286. toFormat(decimalPlaces: number, roundingMode: BigNumber.RoundingMode, format?: BigNumber.Format): string;
  1287. toFormat(decimalPlaces: number, roundingMode?: BigNumber.RoundingMode): string;
  1288. toFormat(decimalPlaces?: number): string;
  1289. toFormat(decimalPlaces: number, format: BigNumber.Format): string;
  1290. toFormat(format: BigNumber.Format): string;
  1291. /**
  1292. * Returns an array of two BigNumbers representing the value of this BigNumber as a simple
  1293. * fraction with an integer numerator and an integer denominator.
  1294. * The denominator will be a positive non-zero value less than or equal to `max_denominator`.
  1295. * If a maximum denominator, `max_denominator`, is not specified, the denominator will be the
  1296. * lowest value necessary to represent the number exactly.
  1297. *
  1298. * Throws if `max_denominator` is invalid.
  1299. *
  1300. * ```ts
  1301. * x = new BigNumber(1.75)
  1302. * x.toFraction() // '7, 4'
  1303. *
  1304. * pi = new BigNumber('3.14159265358')
  1305. * pi.toFraction() // '157079632679,50000000000'
  1306. * pi.toFraction(100000) // '312689, 99532'
  1307. * pi.toFraction(10000) // '355, 113'
  1308. * pi.toFraction(100) // '311, 99'
  1309. * pi.toFraction(10) // '22, 7'
  1310. * pi.toFraction(1) // '3, 1'
  1311. * ```
  1312. *
  1313. * @param [max_denominator] The maximum denominator, integer > 0, or Infinity.
  1314. */
  1315. toFraction(max_denominator?: BigNumber.Value): [BigNumber, BigNumber];
  1316. /** As `valueOf`. */
  1317. toJSON(): string;
  1318. /**
  1319. * Returns the value of this BigNumber as a JavaScript primitive number.
  1320. *
  1321. * Using the unary plus operator gives the same result.
  1322. *
  1323. * ```ts
  1324. * x = new BigNumber(456.789)
  1325. * x.toNumber() // 456.789
  1326. * +x // 456.789
  1327. *
  1328. * y = new BigNumber('45987349857634085409857349856430985')
  1329. * y.toNumber() // 4.598734985763409e+34
  1330. *
  1331. * z = new BigNumber(-0)
  1332. * 1 / z.toNumber() // -Infinity
  1333. * 1 / +z // -Infinity
  1334. * ```
  1335. */
  1336. toNumber(): number;
  1337. /**
  1338. * Returns a string representing the value of this BigNumber rounded to `significantDigits`
  1339. * significant digits using rounding mode `roundingMode`.
  1340. *
  1341. * If `significantDigits` is less than the number of digits necessary to represent the integer
  1342. * part of the value in normal (fixed-point) notation, then exponential notation is used.
  1343. *
  1344. * If `significantDigits` is omitted, then the return value is the same as `n.toString()`.
  1345. *
  1346. * If `roundingMode` is omitted, `ROUNDING_MODE` is used.
  1347. *
  1348. * Throws if `significantDigits` or `roundingMode` is invalid.
  1349. *
  1350. * ```ts
  1351. * x = 45.6
  1352. * y = new BigNumber(x)
  1353. * x.toPrecision() // '45.6'
  1354. * y.toPrecision() // '45.6'
  1355. * x.toPrecision(1) // '5e+1'
  1356. * y.toPrecision(1) // '5e+1'
  1357. * y.toPrecision(2, 0) // '4.6e+1' (ROUND_UP)
  1358. * y.toPrecision(2, 1) // '4.5e+1' (ROUND_DOWN)
  1359. * x.toPrecision(5) // '45.600'
  1360. * y.toPrecision(5) // '45.600'
  1361. * ```
  1362. *
  1363. * @param [significantDigits] Significant digits, integer, 1 to 1e+9.
  1364. * @param [roundingMode] Rounding mode, integer 0 to 8.
  1365. */
  1366. toPrecision(significantDigits: number, roundingMode?: BigNumber.RoundingMode): string;
  1367. toPrecision(): string;
  1368. /**
  1369. * Returns a string representing the value of this BigNumber in base `base`, or base 10 if `base`
  1370. * is omitted.
  1371. *
  1372. * For bases above 10, and using the default base conversion alphabet (see `ALPHABET`), values
  1373. * from 10 to 35 are represented by a-z (the same as `Number.prototype.toString`).
  1374. *
  1375. * If a base is specified the value is rounded according to the current `DECIMAL_PLACES` and
  1376. * `ROUNDING_MODE` settings, otherwise it is not.
  1377. *
  1378. * If a base is not specified, and this BigNumber has a positive exponent that is equal to or
  1379. * greater than the positive component of the current `EXPONENTIAL_AT` setting, or a negative
  1380. * exponent equal to or less than the negative component of the setting, then exponential notation
  1381. * is returned.
  1382. *
  1383. * Throws if `base` is invalid.
  1384. *
  1385. * ```ts
  1386. * x = new BigNumber(750000)
  1387. * x.toString() // '750000'
  1388. * BigNumber.config({ EXPONENTIAL_AT: 5 })
  1389. * x.toString() // '7.5e+5'
  1390. *
  1391. * y = new BigNumber(362.875)
  1392. * y.toString(2) // '101101010.111'
  1393. * y.toString(9) // '442.77777777777777777778'
  1394. * y.toString(32) // 'ba.s'
  1395. *
  1396. * BigNumber.config({ DECIMAL_PLACES: 4 });
  1397. * z = new BigNumber('1.23456789')
  1398. * z.toString() // '1.23456789'
  1399. * z.toString(10) // '1.2346'
  1400. * ```
  1401. *
  1402. * @param [base] The base, integer, 2 to 36 (or `ALPHABET.length`, see `ALPHABET`).
  1403. */
  1404. toString(base?: number): string;
  1405. /**
  1406. * As `toString`, but does not accept a base argument and includes the minus sign for negative
  1407. * zero.
  1408. *
  1409. * ``ts
  1410. * x = new BigNumber('-0')
  1411. * x.toString() // '0'
  1412. * x.valueOf() // '-0'
  1413. * y = new BigNumber('1.777e+457')
  1414. * y.valueOf() // '1.777e+457'
  1415. * ```
  1416. */
  1417. valueOf(): string;
  1418. /** Helps ES6 import. */
  1419. private static readonly default: BigNumber.Constructor;
  1420. /** Helps ES6 import. */
  1421. private static readonly BigNumber: BigNumber.Constructor;
  1422. /** Rounds away from zero. */
  1423. static readonly ROUND_UP: 0;
  1424. /** Rounds towards zero. */
  1425. static readonly ROUND_DOWN: 1;
  1426. /** Rounds towards Infinity. */
  1427. static readonly ROUND_CEIL: 2;
  1428. /** Rounds towards -Infinity. */
  1429. static readonly ROUND_FLOOR: 3;
  1430. /** Rounds towards nearest neighbour. If equidistant, rounds away from zero . */
  1431. static readonly ROUND_HALF_UP: 4;
  1432. /** Rounds towards nearest neighbour. If equidistant, rounds towards zero. */
  1433. static readonly ROUND_HALF_DOWN: 5;
  1434. /** Rounds towards nearest neighbour. If equidistant, rounds towards even neighbour. */
  1435. static readonly ROUND_HALF_EVEN: 6;
  1436. /** Rounds towards nearest neighbour. If equidistant, rounds towards Infinity. */
  1437. static readonly ROUND_HALF_CEIL: 7;
  1438. /** Rounds towards nearest neighbour. If equidistant, rounds towards -Infinity. */
  1439. static readonly ROUND_HALF_FLOOR: 8;
  1440. /** See `MODULO_MODE`. */
  1441. static readonly EUCLID: 9;
  1442. /**
  1443. * To aid in debugging, if a `BigNumber.DEBUG` property is `true` then an error will be thrown
  1444. * if the BigNumber constructor receives an invalid `BigNumber.Value`, or if `BigNumber.isBigNumber`
  1445. * receives a BigNumber instance that is malformed.
  1446. *
  1447. * ```ts
  1448. * // No error, and BigNumber NaN is returned.
  1449. * new BigNumber('blurgh') // 'NaN'
  1450. * new BigNumber(9, 2) // 'NaN'
  1451. * BigNumber.DEBUG = true
  1452. * new BigNumber('blurgh') // '[BigNumber Error] Not a number'
  1453. * new BigNumber(9, 2) // '[BigNumber Error] Not a base 2 number'
  1454. * ```
  1455. *
  1456. * An error will also be thrown if a `BigNumber.Value` is of type number with more than 15
  1457. * significant digits, as calling `toString` or `valueOf` on such numbers may not result
  1458. * in the intended value.
  1459. *
  1460. * ```ts
  1461. * console.log(823456789123456.3) // 823456789123456.2
  1462. * // No error, and the returned BigNumber does not have the same value as the number literal.
  1463. * new BigNumber(823456789123456.3) // '823456789123456.2'
  1464. * BigNumber.DEBUG = true
  1465. * new BigNumber(823456789123456.3)
  1466. * // '[BigNumber Error] Number primitive has more than 15 significant digits'
  1467. * ```
  1468. *
  1469. * Check that a BigNumber instance is well-formed:
  1470. *
  1471. * ```ts
  1472. * x = new BigNumber(10)
  1473. *
  1474. * BigNumber.DEBUG = false
  1475. * // Change x.c to an illegitimate value.
  1476. * x.c = NaN
  1477. * // No error, as BigNumber.DEBUG is false.
  1478. * BigNumber.isBigNumber(x) // true
  1479. *
  1480. * BigNumber.DEBUG = true
  1481. * BigNumber.isBigNumber(x) // '[BigNumber Error] Invalid BigNumber'
  1482. * ```
  1483. */
  1484. static DEBUG?: boolean;
  1485. /**
  1486. * Returns a new independent BigNumber constructor with configuration as described by `object`, or
  1487. * with the default configuration if object is omitted.
  1488. *
  1489. * Throws if `object` is not an object.
  1490. *
  1491. * ```ts
  1492. * BigNumber.config({ DECIMAL_PLACES: 5 })
  1493. * BN = BigNumber.clone({ DECIMAL_PLACES: 9 })
  1494. *
  1495. * x = new BigNumber(1)
  1496. * y = new BN(1)
  1497. *
  1498. * x.div(3) // 0.33333
  1499. * y.div(3) // 0.333333333
  1500. *
  1501. * // BN = BigNumber.clone({ DECIMAL_PLACES: 9 }) is equivalent to:
  1502. * BN = BigNumber.clone()
  1503. * BN.config({ DECIMAL_PLACES: 9 })
  1504. * ```
  1505. *
  1506. * @param [object] The configuration object.
  1507. */
  1508. static clone(object?: BigNumber.Config): BigNumber.Constructor;
  1509. /**
  1510. * Configures the settings that apply to this BigNumber constructor.
  1511. *
  1512. * The configuration object, `object`, contains any number of the properties shown in the example
  1513. * below.
  1514. *
  1515. * Returns an object with the above properties and their current values.
  1516. *
  1517. * Throws if `object` is not an object, or if an invalid value is assigned to one or more of the
  1518. * properties.
  1519. *
  1520. * ```ts
  1521. * BigNumber.config({
  1522. * DECIMAL_PLACES: 40,
  1523. * ROUNDING_MODE: BigNumber.ROUND_HALF_CEIL,
  1524. * EXPONENTIAL_AT: [-10, 20],
  1525. * RANGE: [-500, 500],
  1526. * CRYPTO: true,
  1527. * MODULO_MODE: BigNumber.ROUND_FLOOR,
  1528. * POW_PRECISION: 80,
  1529. * FORMAT: {
  1530. * groupSize: 3,
  1531. * groupSeparator: ' ',
  1532. * decimalSeparator: ','
  1533. * },
  1534. * ALPHABET: '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_'
  1535. * });
  1536. *
  1537. * BigNumber.config().DECIMAL_PLACES // 40
  1538. * ```
  1539. *
  1540. * @param object The configuration object.
  1541. */
  1542. static config(object?: BigNumber.Config): BigNumber.Config;
  1543. /**
  1544. * Returns `true` if `value` is a BigNumber instance, otherwise returns `false`.
  1545. *
  1546. * If `BigNumber.DEBUG` is `true`, throws if a BigNumber instance is not well-formed.
  1547. *
  1548. * ```ts
  1549. * x = 42
  1550. * y = new BigNumber(x)
  1551. *
  1552. * BigNumber.isBigNumber(x) // false
  1553. * y instanceof BigNumber // true
  1554. * BigNumber.isBigNumber(y) // true
  1555. *
  1556. * BN = BigNumber.clone();
  1557. * z = new BN(x)
  1558. * z instanceof BigNumber // false
  1559. * BigNumber.isBigNumber(z) // true
  1560. * ```
  1561. *
  1562. * @param value The value to test.
  1563. */
  1564. static isBigNumber(value: any): value is BigNumber;
  1565. /**
  1566. * Returns a BigNumber whose value is the maximum of the arguments.
  1567. *
  1568. * The return value is always exact and unrounded.
  1569. *
  1570. * ```ts
  1571. * x = new BigNumber('3257869345.0378653')
  1572. * BigNumber.maximum(4e9, x, '123456789.9') // '4000000000'
  1573. *
  1574. * arr = [12, '13', new BigNumber(14)]
  1575. * BigNumber.maximum.apply(null, arr) // '14'
  1576. * ```
  1577. *
  1578. * @param n A numeric value.
  1579. */
  1580. static maximum(...n: BigNumber.Value[]): BigNumber;
  1581. /**
  1582. * Returns a BigNumber whose value is the maximum of the arguments.
  1583. *
  1584. * The return value is always exact and unrounded.
  1585. *
  1586. * ```ts
  1587. * x = new BigNumber('3257869345.0378653')
  1588. * BigNumber.max(4e9, x, '123456789.9') // '4000000000'
  1589. *
  1590. * arr = [12, '13', new BigNumber(14)]
  1591. * BigNumber.max.apply(null, arr) // '14'
  1592. * ```
  1593. *
  1594. * @param n A numeric value.
  1595. */
  1596. static max(...n: BigNumber.Value[]): BigNumber;
  1597. /**
  1598. * Returns a BigNumber whose value is the minimum of the arguments.
  1599. *
  1600. * The return value is always exact and unrounded.
  1601. *
  1602. * ```ts
  1603. * x = new BigNumber('3257869345.0378653')
  1604. * BigNumber.minimum(4e9, x, '123456789.9') // '123456789.9'
  1605. *
  1606. * arr = [2, new BigNumber(-14), '-15.9999', -12]
  1607. * BigNumber.minimum.apply(null, arr) // '-15.9999'
  1608. * ```
  1609. *
  1610. * @param n A numeric value.
  1611. */
  1612. static minimum(...n: BigNumber.Value[]): BigNumber;
  1613. /**
  1614. * Returns a BigNumber whose value is the minimum of the arguments.
  1615. *
  1616. * The return value is always exact and unrounded.
  1617. *
  1618. * ```ts
  1619. * x = new BigNumber('3257869345.0378653')
  1620. * BigNumber.min(4e9, x, '123456789.9') // '123456789.9'
  1621. *
  1622. * arr = [2, new BigNumber(-14), '-15.9999', -12]
  1623. * BigNumber.min.apply(null, arr) // '-15.9999'
  1624. * ```
  1625. *
  1626. * @param n A numeric value.
  1627. */
  1628. static min(...n: BigNumber.Value[]): BigNumber;
  1629. /**
  1630. * Returns a new BigNumber with a pseudo-random value equal to or greater than 0 and less than 1.
  1631. *
  1632. * The return value will have `decimalPlaces` decimal places, or less if trailing zeros are
  1633. * produced. If `decimalPlaces` is omitted, the current `DECIMAL_PLACES` setting will be used.
  1634. *
  1635. * Depending on the value of this BigNumber constructor's `CRYPTO` setting and the support for the
  1636. * `crypto` object in the host environment, the random digits of the return value are generated by
  1637. * either `Math.random` (fastest), `crypto.getRandomValues` (Web Cryptography API in recent
  1638. * browsers) or `crypto.randomBytes` (Node.js).
  1639. *
  1640. * To be able to set `CRYPTO` to true when using Node.js, the `crypto` object must be available
  1641. * globally:
  1642. *
  1643. * ```ts
  1644. * global.crypto = require('crypto')
  1645. * ```
  1646. *
  1647. * If `CRYPTO` is true, i.e. one of the `crypto` methods is to be used, the value of a returned
  1648. * BigNumber should be cryptographically secure and statistically indistinguishable from a random
  1649. * value.
  1650. *
  1651. * Throws if `decimalPlaces` is invalid.
  1652. *
  1653. * ```ts
  1654. * BigNumber.config({ DECIMAL_PLACES: 10 })
  1655. * BigNumber.random() // '0.4117936847'
  1656. * BigNumber.random(20) // '0.78193327636914089009'
  1657. * ```
  1658. *
  1659. * @param [decimalPlaces] Decimal places, integer, 0 to 1e+9.
  1660. */
  1661. static random(decimalPlaces?: number): BigNumber;
  1662. /**
  1663. * Returns a BigNumber whose value is the sum of the arguments.
  1664. *
  1665. * The return value is always exact and unrounded.
  1666. *
  1667. * ```ts
  1668. * x = new BigNumber('3257869345.0378653')
  1669. * BigNumber.sum(4e9, x, '123456789.9') // '7381326134.9378653'
  1670. *
  1671. * arr = [2, new BigNumber(14), '15.9999', 12]
  1672. * BigNumber.sum.apply(null, arr) // '43.9999'
  1673. * ```
  1674. *
  1675. * @param n A numeric value.
  1676. */
  1677. static sum(...n: BigNumber.Value[]): BigNumber;
  1678. /**
  1679. * Configures the settings that apply to this BigNumber constructor.
  1680. *
  1681. * The configuration object, `object`, contains any number of the properties shown in the example
  1682. * below.
  1683. *
  1684. * Returns an object with the above properties and their current values.
  1685. *
  1686. * Throws if `object` is not an object, or if an invalid value is assigned to one or more of the
  1687. * properties.
  1688. *
  1689. * ```ts
  1690. * BigNumber.set({
  1691. * DECIMAL_PLACES: 40,
  1692. * ROUNDING_MODE: BigNumber.ROUND_HALF_CEIL,
  1693. * EXPONENTIAL_AT: [-10, 20],
  1694. * RANGE: [-500, 500],
  1695. * CRYPTO: true,
  1696. * MODULO_MODE: BigNumber.ROUND_FLOOR,
  1697. * POW_PRECISION: 80,
  1698. * FORMAT: {
  1699. * groupSize: 3,
  1700. * groupSeparator: ' ',
  1701. * decimalSeparator: ','
  1702. * },
  1703. * ALPHABET: '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_'
  1704. * });
  1705. *
  1706. * BigNumber.set().DECIMAL_PLACES // 40
  1707. * ```
  1708. *
  1709. * @param object The configuration object.
  1710. */
  1711. static set(object?: BigNumber.Config): BigNumber.Config;
  1712. }
  1713. declare function BigNumber(n: BigNumber.Value, base?: number): BigNumber;