bignumber.d.ts 61 KB

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