bignumber.d.ts 64 KB

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