File: index.html

package info (click to toggle)
node-big.js 6.0.3%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 3,476 kB
  • sloc: javascript: 32,771; makefile: 4
file content (1319 lines) | stat: -rw-r--r-- 48,985 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
<!DOCTYPE HTML>
<html>
<head>
  <meta charset="utf-8">
  <meta name="Author" content="M Mclaughlin">
  <title>big.js API</title>
  <style>
html{font-family:sans-serif;font-size:100%}
body{font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:13px;
  line-height:1.65em;background:#fff;min-height:100%;margin:0}
body,i{color:#000}
.nav{background:#fff;position:fixed;top:0;bottom:0;left:0;width:130px;
  overflow-y:auto;padding:15px 0 30px 20px; border-right: 1px solid #69d2e7}
div.container{width:700px;margin:30px 0 50px 190px}
p{margin:0 0 1em;width:700px}
pre,ul{margin:1em 0}
h1,h2,h3,h4,h5{margin:0;padding:1.5em 0 0}
h1,h2{padding:.75em 0 1em}
h1{font:400 3em Consolas, monaco, monospace;color:#000;margin-bottom:1em}
h2{font-size:2.25em;color:#f00}
h3{font-size:1.75em;color:#69d2e7}
h4{font-size:1.75em;color:#f00;padding-bottom:.75em}
h5{font-size:1.2em;padding-bottom:.3em}
h6{font-size:1.1em;margin:0;padding:0.5em 0}
b{font-weight:700}
a,a:visited{color:#f00;text-decoration:none}
a:active,a:hover{outline:0;text-decoration:underline}
a:hover{text-decoration:underline}
.nav a,.nav b,.nav a:visited{display:block;color:#f00;font-weight:700;
  margin-top:15px}
.nav b{color:#69d2e7;margin-top:20px;cursor:default;width:auto}
ul{list-style-type:none;padding:0 0 0 20px}
.nav ul{line-height:14px;padding-left:0;margin:5px 0 0}
.nav ul a,.nav ul a:visited{display:inline;color:#000;font-family:Verdana,
  Geneva,sans-serif;font-size:11px;font-weight:400;margin:0}
.inset,ul.inset{margin-left:20px}
code.inset{font-size:.9em}
.nav li{cursor:pointer;width:auto;margin:0 0 3px}
span.alias{font-style:italic;margin-left:20px}
table{border-collapse:collapse;border-spacing:0;border:2px solid #a7dbd8;
  margin:1.75em 0;padding:0}
td,th{text-align:left;margin:0;padding:2px 10px;border:1px dotted #a7dbd8}
th{border-top:2px solid #a7dbd8;border-bottom:2px solid #a7dbd8;color:#f00}
pre{background:#f5f5f5;white-space:pre-wrap;word-wrap:break-word;
  border-left:5px solid #a7dbd8;padding:1px 0 1px 15px;margin:1.2em 0}
code,pre{font-family:Monaco,Consolas,"Lucida Console",monospace;
  font-weight:400}
.end{margin-bottom:25px}
code, .nav-title, .error{color:#f00}
.centre{text-align:center}

  </style>
</head>
<body>

  <div class="nav">

    <a class='nav-title' href="#">API</a>
    <select id="version" name="version" onchange="location.href=this.value;this.selectedIndex=0">
      <option value="" selected>v6.0.x</option>
      <option value="legacy/v5.2.x.html">v5.2.x</option>
      <option value="legacy/v5.1.x.html">v5.1.x</option>
      <option value="legacy/v5.0.x.html">v5.0.x</option>
      <option value="legacy/v4.x.x.html">v4.x.x</option>
      <option value="legacy/v3.2.x.html">v3.2.x</option>
      <option value="legacy/v3.1.x.html">v3.1.x</option>
      <option value="legacy/v3.0.x.html">v3.0.x</option>
      <option value="legacy/v2.x.x.html">v2.x.x</option>
      <option value="legacy/v1.x.x.html">v1.x.x</option>
    </select>

    <b> CONSTRUCTOR </b>
    <ul>
      <li><a href="#big">Big</a></li>
    </ul>

    <a href="#constructor-properties">Properties</a>
    <ul>
      <li><a href="#dp"    >DP</a></li>
      <li><a href="#rm"    >RM</a></li>
      <li><a href="#eneg"  >NE</a></li>
      <li><a href="#epos"  >PE</a></li>
      <li><a href="#strict">strict</a></li>
    </ul>

    <b> INSTANCE </b>

    <a href="#prototype-methods">Methods</a>
    <ul>
      <li><a href="#abs"    >abs</a></li>
      <li><a href="#cmp"    >cmp</a></li>
      <li><a href="#div"    >div</a></li>
      <li><a href="#eq"     >eq</a></li>
      <li><a href="#gt"     >gt</a></li>
      <li><a href="#gte"    >gte</a></li>
      <li><a href="#lt"     >lt</a></li>
      <li><a href="#lte"    >lte</a></li>
      <li><a href="#minus"  >minus</a></li>
      <li><a href="#mod"    >mod</a></li>
      <li><a href="#plus"   >plus</a></li>
      <li><a href="#pow"    >pow</a></li>
      <li><a href="#prec"   >prec</a></li>
      <li><a href="#round"  >round</a></li>
      <li><a href="#sqrt"   >sqrt</a></li>
      <li><a href="#times"  >times</a></li>
      <li><a href="#toE"    >toExponential</a></li>
      <li><a href="#toF"    >toFixed</a></li>
      <li><a href="#toJSON" >toJSON</a></li>
      <li><a href="#toN"    >toNumber</a></li>
      <li><a href="#toP"    >toPrecision</a></li>
      <li><a href="#toS"    >toString</a></li>
      <li><a href="#valueOf">valueOf</a></li>
    </ul>

    <a href="#instance-properties">Properties</a>
    <ul>
      <li><a href="#coefficient">c : coefficient</a></li>
      <li><a href="#exponent"   >e : exponent</a></li>
      <li><a href="#sign"       >s : sign</a></li>
    </ul>

    <a href="#Errors">Errors</a>

    <a class='end' href="#faq">FAQ</a>

  </div>

  <div class="container">

    <h1>big.js</h1>

    <p>
      A small, fast, easy-to-use library for arbitrary-precision decimal
      arithmetic.
    </p>

    <p><a href="https://github.com/MikeMcl/big.js/">Hosted on GitHub</a>.</p>
    <p>
      <i>
        The library is incorporated into this page, so it should be available in
        the console now.
      </i>
    </p>

    <h2>API</h2>

    <p>
      In all examples below, <code>var</code> and semicolons are not shown, and
      if a commented-out value is in quotes it means <code>toString</code> has
      been called on the preceding expression.
    </p>



    <h3>CONSTRUCTOR</h3>

    <h5 id="big">
      Big<code class='inset'>Big(n) <i>&rArr; Big</i></code>
    </h5>
    <p><code>n</code> : <i>number|string|Big</i> : a decimal value</p>
    <p>
      By default, the argument <code>n</code> can be a number, string or Big number,
      but if <a href='#strict'><code>Big.strict</code></a> is set to <code>true</code>
      an error will be thrown if <code>n</code> is not a string or Big number.
    </p>
    <p>
      <code>Infinity</code>, <code>NaN</code> and hexadecimal literal
      strings, e.g. '0xff', are <u>not</u> valid.
    </p>
    <p>
      String values in octal literal form will be interpreted as decimals,
      e.g. '011' is 11, not 9.
    </p>
    <p>
      String values may be in exponential, as well as normal (non-exponential)
      notation.
    </p>
    <p>
      There is no limit to the number of digits of a <em>string</em> value
      (other than that of JavaScript's maximum array size), but the largest
      recommended exponent magnitude is 1000000.
    </p>
    <p>Returns a new Big number object with value <code>n</code>.</p>
    <p>Throws if <code>n</code> is invalid.</p>
    <p>
      Using <code>new</code> with Big is optional, but note that if no argument
      is passed when doing so, or if the argument is <code>undefined</code>,
      then a new Big constructor will be returned rather than a new Big number
      instance. See <a href='#multiple'>creating additional Big number constructors</a>
      below.
    </p>
    <pre>
x = new Big(9)                       // '9'
y = new Big(x)                       // '9'
new Big('5032485723458348569331745.33434346346912144534543')
new Big('4.321e+4')                  // '43210'
new Big('-735.0918e-430')            // '-7.350918e-428'
Big(435.345)                         // '435.345'
new Big()                            // 'Error: [big.js] Invalid value'
Big()                                // No error, and a new Big constructor is returned
    </pre>



    <h4 id="constructor-properties">Properties</h4>

    <h5 id="dp">DP</h5>
    <p>
      <i>number</i> : integer, 0 to 1e+6 inclusive<br />
      Default value: <code>20</code>
    </p>
    <p>
      The <u>maximum</u> number of decimal places of the results of operations
      involving division.<br />
      It is relevant only to the <code>div</code> and <code>sqrt</code> methods,
      and the <code>pow</code> method when the exponent is negative.
    </p>
    <p>
      The value will be checked for validity when one of the above methods is
      called.<br /> An error will be thrown if the value is found to be invalid.
    </p>
    <pre>Big.DP = 40</pre>



    <h5 id="rm">RM</h5>
    <p>
      <i>number</i> : 0, 1, 2 or 3<br />
      Default value: <code>1</code>
    </p>
    <p>
      The rounding mode used in the above operations and by
      <a href='#round'><code>round</code></a>,
      <a href='#toE'><code>toExponential</code></a>,
      <a href='#toF'><code>toFixed</code></a> and
      <a href='#toP'><code>toPrecision</code></a>.
    </p>
    <table>
      <tr>
        <th>Value</th>
        <th>Description</th>
        <th>BigDecimal equivalent</th>
      </tr>
      <tr>
        <td class='centre'>0</td>
        <td>
          Rounds towards zero.<br />
          I.e. truncate, no rounding.
        </td>
        <td id="round-down">ROUND_DOWN</td>
      </tr>
      <tr>
        <td class='centre'>1</td>
        <td>
          Rounds towards nearest neighbour.<br />
          If equidistant, rounds away from zero.
        </td>
        <td id="round-half-up">ROUND_HALF_UP</td>
      </tr>
      <tr>
        <td class='centre'>2</td>
        <td>
          Rounds towards nearest neighbour.<br />
          If equidistant, rounds towards even neighbour.
        </td>
        <td id="round-half-even">ROUND_HALF_EVEN</td>
      </tr>
      <tr>
        <td class='centre'>3</td>
        <td>Rounds away from zero.</td>
        <td id="round-up">ROUND_UP</td>
      </tr>
    </table>
    <p>
      The value will be checked for validity when one of the above methods is
      called.<br /> An error will be thrown if the value is found to be invalid.
    </p>
    <pre>Big.RM = 0</pre>



    <h5 id="eneg">NE</h5>
    <p>
      <i>number</i> : integer, -1e+6 to 0 inclusive<br />
      Default value: <code>-7</code>
    </p>
    <p>
      The negative exponent value at and below which
      <a href='#toS'><code>toString</code></a> returns exponential notation.
    </p>
    <pre>
Big.NE = -7
x = new Big(0.00000123)            // '0.00000123'       e is -6
x = new Big(0.000000123)           // '1.23e-7'</pre>
    <p>
      JavaScript numbers use exponential notation for negative exponents of
      <code>-7</code> and below.
    </p>
    <p>
      Regardless of the value of <code>Big.NE</code>, the
      <a href='#toF'><code>toFixed</code></a> method will always return a value
      in normal notation and the <a href='#toE'><code>toExponential</code></a>
      method will always return a value in exponential form.
    </p>



    <h5 id="epos">PE</h5>
    <p>
      <i>number</i> : integer, 0 to 1e+6 inclusive<br />
      Default value: <code>21</code>
    </p>
    <p>
      The positive exponent value at and above which
      <a href='#toS'><code>toString</code></a> returns exponential notation.
    </p>
    <pre>
Big.PE = 2
x = new Big(12.3)                  // '12.3'        e is 1
x = new Big(123)                   // '1.23e+2'</pre>
    <p>
      JavaScript numbers use exponential notation for positive exponents of
      <code>21</code> and above.
    </p>
    <p>
      Regardless of the value of <code>Big.PE</code>, the
      <a href='#toF'><code>toFixed</code></a> method will always return a value
      in normal notation and the <a href='#toE'><code>toExponential</code></a>
      method will always return a value in exponential form.
    </p>



    <h5 id="strict">strict</h5>
    <p>
      <i>true|false</i><br />
      Default value: <code>false</code>
    </p>
    <p>
      When set to <code>true</code>, an error will be thrown if a primitive number
      is passed to the Big constructor, or if <a href='#valueOf'><code>valueOf</code></a>
      is called, or if <a href='#toN'><code>toNumber</code></a> is called on a Big
      which cannot be converted to a primitive number without a loss of precision.
    </p>
    <pre>
Big.strict = true
x = new Big(1)                    // 'TypeError: [big.js] String expected'
y = new Big('1.000000000000000000001')
2 + y                             // 'Error: [big.js] valueOf disallowed'
y.toNumber()                      // 'Error: [big.js] Imprecise conversion'

Big.strict = false
x = new Big(0.1)
y = new Big('1.000000000000000000001')
2 + y                             // '21.000000000000000000001'
y.toNumber()                      // 1</pre>



    <h3>INSTANCE</h3>

    <h4 id="prototype-methods">Methods</h4>
    <p>
      The methods inherited by a Big number instance from its constructor's
      prototype object.
    </p>
    <p>
      A Big number is immutable in the sense that it is not changed by its
      methods.
    </p>



    <h5 id="abs">abs<code class='inset'>.abs() <i>&rArr; Big</i></code></h5>
    <p>
      Returns a Big number whose value is the absolute value, i.e. the
      magnitude, of this Big number.
    </p>
    <pre>
x = new Big(-0.8)
x.abs()                     // '0.8'</pre>



    <h5 id="cmp">
      cmp<code class='inset'>.cmp(n) <i>&rArr; number</i></code>
    </h5>
    <p><code>n</code> : <i>number|string|Big</i><br /></p>
    <table>
      <tr>
        <th>Returns</th>
        <th colspan=2>&nbsp;</th>
      </tr>
      <tr>
        <td class='centre'>1</td>
        <td>
          If the value of this Big number is greater than the value of
          <code>n</code>
        </td>
      </tr>
      <tr>
        <td class='centre'>-1</td>
        <td>
          If the value of this Big number is less than the value of
          <code>n</code>
        </td>
      </tr>
      <tr>
        <td class='centre'>0</td>
        <td>If this Big number and <code>n</code> have the same value</td>
      </tr>
    </table>
    <p>Throws if <code>n</code> is invalid.</p>
    <pre>
x = new Big(6)
y = new Big(5)
x.cmp(y)                   // 1
y.cmp(x.minus(1))          // 0</pre>



    <h5 id="div">div<code class='inset'>.div(n) <i>&rArr; Big</i></code></h5>
    <p><code>n</code> : <i>number|string|Big</i><br /></p>
    <p>
      Returns a Big number whose value is the value of this Big number divided
      by <code>n</code>.
    </p>
    <p>
      If the result has more fraction digits than is specified by
      <a href='#dp'><code>Big.DP</code></a>, it will be rounded to
      <a href='#dp'><code>Big.DP</code></a> decimal places using rounding mode
      <a href='#rm'><code>Big.RM</code></a>.
    </p>
    <p>Throws if <code>n</code> is zero or otherwise invalid.</p>
    <pre>
x = new Big(355)
y = new Big(113)
x.div(y)                   // '3.14159292035398230088'
Big.DP = 2
x.div(y)                   // '3.14'
x.div(5)                   // '71'</pre>



    <h5 id="eq">eq<code class='inset'>.eq(n) <i>&rArr; boolean</i></code></h5>
    <p><code>n</code> : <i>number|string|Big</i></p>
    <p>
      Returns <code>true</code> if the value of this Big number equals the value
      of <code>n</code>, otherwise returns <code>false</code>.
    </p>
    <p>Throws if <code>n</code> is invalid.</p>
    <pre>
0 === 1e-324               // true
x = new Big(0)
x.eq('1e-324')             // false
Big(-0).eq(x)              // true  ( -0 === 0 )</pre>



    <h5 id="gt">
      gt<code class='inset'>.gt(n) <i>&rArr; boolean</i></code>
    </h5>
    <p><code>n</code> : <i>number|string|Big</i></p>
    <p>
      Returns <code>true</code> if the value of this Big number is greater than
      the value of <code>n</code>, otherwise returns <code>false</code>.
    </p>
    <p>Throws if <code>n</code> is invalid.</p>
    <pre>
0.1 &gt; 0.3 - 0.2              // true
x = new Big(0.1)
x.gt(Big(0.3).minus(0.2))    // false
Big(0).gt(x)                 // false</pre>



    <h5 id="gte">
      gte<code class='inset'>.gte(n) <i>&rArr; boolean</i></code>
    </h5>
    <p><code>n</code> : <i>number|string|Big</i></p>
    <p>
      Returns <code>true</code> if the value of this Big number is greater than
      or equal to the value of <code>n</code>, otherwise returns
      <code>false</code>.
    </p>
    <p>Throws if <code>n</code> is invalid.</p>
    <pre>
0.3 - 0.2 &gt;= 0.1               // false
x = new Big(0.3).minus(0.2)
x.gte(0.1)                     // true
Big(1).gte(x)                  // true</pre>



    <h5 id="lt">
      lt<code class='inset'>.lt(n) <i>&rArr; boolean</i></code>
    </h5>
    <p><code>n</code> : <i>number|string|Big</i></p>
    <p>
      Returns <code>true</code> if the value of this Big number is less than the
      value of <code>n</code>, otherwise returns <code>false</code>.
    </p>
    <p>Throws if <code>n</code> is invalid.</p>
    <pre>
0.3 - 0.2 &lt; 0.1                // true
x = new Big(0.3).minus(0.2)
x.lt(0.1)                      // false
Big(0).lt(x)                   // true</pre>



    <h5 id="lte">
      lte<code class='inset'>.lte(n) <i>&rArr; boolean</i></code>
    </h5>
    <p><code>n</code> : <i>number|string|Big</i></p>
    <p>
      Returns <code>true</code> if the value of this Big number is less than or
      equal to the value of <code>n</code>, otherwise returns
      <code>false</code>.
    </p>
    <p>Throws if <code>n</code> is invalid.</p>
    <pre>
0.1 &lt;= 0.3 - 0.2               // false
x = new Big(0.1)
x.lte(Big(0.3).minus(0.2))     // true
Big(-1).lte(x)                 // true</pre>



    <h5 id="minus">
      minus<code class='inset'>.minus(n) <i>&rArr; Big</i></code>
    </h5>
    <p><code>n</code> : <i>number|string|Big</i></p>
    <p>
      Returns a Big number whose value is the value of this Big number minus
      <code>n</code>.
    </p>
    <p>Throws if <code>n</code> is invalid.</p>
    <pre>
0.3 - 0.1                  // 0.19999999999999998
x = new Big(0.3)
x.minus(0.1)               // '0.2'</pre>



    <h5 id="mod">mod<code class='inset'>.mod(n) <i>&rArr; Big</i></code></h5>
    <p><code>n</code> : <i>number|string|Big</i></p>
    <p>
      Returns a Big number whose value is the value of this Big number modulo
      <code>n</code>, i.e. the integer remainder of dividing this Big number by
      <code>n</code>.
    </p>
    <p>
      The result will have the same sign as this Big number, and it will match
      that of JavaScript's % operator (within the limits of its precision) and
      BigDecimal's remainder method.
    </p>
     <p>Throws if <code>n</code> is zero or otherwise invalid.</p>
    <pre>
1 % 0.9                    // 0.09999999999999998
x = new Big(1)
x.mod(0.9)                 // '0.1'</pre>



    <h5 id="plus">
      plus<code class='inset'>.plus(n) <i>&rArr; Big</i></code>
    </h5>
    <p><code>n</code> : <i>number|string|Big</i></p>
    <p>
      Returns a Big number whose value is the value of this Big number plus
      <code>n</code>.
    </p>
    <p>Throws if <code>n</code> is invalid.</p>
    <pre>
0.1 + 0.2                  // 0.30000000000000004
x = new Big(0.1)
y = x.plus(0.2)            // '0.3'
Big(0.7).plus(x).plus(y)   // '1.1'</pre>



    <h5 id="pow">pow<code class='inset'>.pow(n) <i>&rArr; Big</i></code>
    </h5>
    <p>
      <code>n</code> : <i>number</i> : integer, -1e+6 to 1e+6 inclusive
    </p>
    <p>
      Returns a Big number whose value is the value of this Big number raised to
      the power <code>n</code>.
    </p>
    <p>
      Here, <code>n</code> must be a JavaScript number, not a Big number,
      because only small integers are allowed.
    </p>
    <p>
      If <code>n</code> is negative and the result has more fraction digits
      than is specified by <a href='#dp'><code>Big.DP</code></a>, it will be
      rounded to <a href='#dp'><code>Big.DP</code></a> decimal places using
      rounding mode <a href='#rm'><code>Big.RM</code></a>.
    </p>
    <p>
      Throws if <code>n</code> is invalid.
    </p>
    <p>
      Note: High value exponents may cause this method to be slow to return.
    </p>
    <pre>
Math.pow(0.7, 2)           // 0.48999999999999994
x = new Big(0.7)
x.pow(2)                   // '0.49'
Big.DP = 20
Big(3).pow(-2)             // '0.11111111111111111111'

new Big(123.456).pow(1000).toString().length     // 5099
new Big(2).pow(1e+6)       // Time taken (Node.js): 9 minutes 34 secs.</pre>



    <h5 id="prec">prec<code class='inset'>.prec(sd, rm)<i>&rArr; Big</i></code></h5>
    <p>
      <code>sd</code>? : <i>number</i> : integer, 1 to 1e+6 inclusive
      <br />
      <code>rm</code>? : <i>number</i> : 0, 1, 2 or 3
    </p>
    <p>
      Returns a Big number whose value is the value of this Big number rounded
      to a maximum precision of <code>sd</code> significant digits using rounding mode
      <code>rm</code>, or <a href='#rm'><code>Big.RM</code></a> if <code>rm</code> is
      omitted or undefined.
    </p>
    <p>
      Throws if <code>sd</code> or <code>rm</code> is invalid.
    </p>
    <pre>
down = 0
half_up = 1
x = new Big('9876.54321')
x.prec(2)                 // '9900'
x.prec(7)                 // '9876.543'
x.prec(20)                // '9876.54321'
x.prec(1, down)           // '9000'
x.prec(1, half_up)        // '10000'
x                         // '9876.54321'</pre>



    <h5 id="round">
      round<code class='inset'>.round(dp, rm)
      <i>&rArr; Big</i></code>
    </h5>
    <p>
      <code>dp</code>? : <i>number</i> : integer, -1e+6 to 1e+6 inclusive
      <br />
      <code>rm</code>? : <i>number</i> : 0, 1, 2 or 3
    </p>
    <p>
      Returns a Big number whose value is the value of this Big number rounded
      using rounding mode <code>rm</code> to a maximum of <code>dp</code>
      decimal places, or, if <code>dp</code> is negative, to an integer which
      is a multiple of <code>10**-dp</code>.
    </p>
    <p>
      if <code>dp</code> is omitted or is undefined, the return value is the value of this Big
      number rounded to a whole number.<br />
      if <code>rm</code> is omitted or is undefined, the current
      <a href='#rm'><code>Big.RM</code></a> setting is used.
    </p>
    <p>
      Throws if <code>dp</code> or <code>rm</code> is invalid.
    </p>
    <pre>
down = 0
half_up = 1
half_even = 2
up = 3

x = 123.45
Math.round(x)              // 123

y = new Big(x)
y.round()                  // '123'
y.round(2)                 // '123.45'
y.round(10)                // '123.45'
y.round(1, down)           // '123.4'
y.round(1, half_up)        // '123.5'
y.round(1, half_even)      // '123.4'
y.round(1, up)             // '123.5'
y.round(-1, down)          // '120'
y.round(-2, up)            // '200'
y                          // '123.45'</pre>



    <h5 id="sqrt">sqrt<code class='inset'>.sqrt() <i>&rArr; Big</i></code></h5>
    <p>
      Returns a Big number whose value is the square root of this Big number.
    </p>
    <p>
      If the result has more fraction digits than is specified by
      <a href='#dp'><code>Big.DP</code></a>, it will be rounded to
      <a href='#dp'><code>Big.DP</code></a> decimal places using rounding mode
      <a href='#rm'><code>Big.RM</code></a>.
    </p>
    <p>Throws if this Big number is negative.</p>
    <pre>
x = new Big(16)
x.sqrt()                   // '4'
y = new Big(3)
y.sqrt()                   // '1.73205080756887729353'</pre>



    <h5 id="times">
      times<code class='inset'>.times(n) <i>&rArr; Big</i></code>
    </h5>
    <p><code>n</code> : <i>number|string|Big</i><br /></p>
    <p>
      Returns a Big number whose value is the value of this Big number times
      <code>n</code>.
    </p>
    <p>Throws if <code>n</code> is invalid.</p>
    <pre>
0.6 * 3                    // 1.7999999999999998
x = new Big(0.6)
y = x.times(3)             // '1.8'
Big('7e+500').times(y)     // '1.26e+501'</pre>



    <h5 id="toE">
      toExponential<code class='inset'>.toExponential(dp) &rArr;
      <i>string</i></code>
    </h5>
    <p><code>dp</code>? : <i>number</i> : integer, 0 to 1e+6 inclusive</p>
    <p>
      Returns a string representing the value of this Big number in exponential
      notation to a fixed number of <code>dp</code> decimal places.
    </p>
    <p>
      If the value of this Big number in exponential notation has more digits to
      the right of the decimal point than is specified by <code>dp</code>, the
      return value will be rounded to <code>dp</code> decimal places using
      rounding mode <a href='#rm'><code>Big.RM</code></a>.
    </p>
    <p>
      If the value of this Big number in exponential notation has fewer digits
      to the right of the decimal point than is specified by <code>dp</code>,
      the return value will be appended with zeros accordingly.
    </p>
    <p>
      If <code>dp</code> is omitted or is undefined, the number of digits
      after the decimal point defaults to the minimum number of digits
      necessary to represent the value exactly.
    </p>
    <p>
      Throws if <code>dp</code> is invalid.
    </p>
    <pre>
x = 45.6
y = new Big(x)
x.toExponential()          // '4.56e+1'
y.toExponential()          // '4.56e+1'
x.toExponential(0)         // '5e+1'
y.toExponential(0)         // '5e+1'
x.toExponential(1)         // '4.6e+1'
y.toExponential(1)         // '4.6e+1'
x.toExponential(3)         // '4.560e+1'
y.toExponential(3)         // '4.560e+1'</pre>



    <h5 id="toF">
      toFixed<code class='inset'>.toFixed(dp) &rArr;
      <i>string</i></code>
    </h5>
    <p>
      <code>dp</code>? : <i>number</i> : integer, 0 to 1e+6 inclusive
    </p>
    <p>
      Returns a string representing the value of this Big number in normal
      notation to a fixed number of <code>dp</code> decimal places.
    </p>
    <p>
      If the value of this Big number in normal notation has more digits to the
      right of the decimal point than is specified by <code>dp</code>, the
      return value will be rounded to <code>dp</code> decimal places using
      rounding mode <a href='#rm'><code>Big.RM</code></a>.
    </p>
    <p>
      If the value of this Big number in normal notation has fewer fraction
      digits then is specified by <code>dp</code>, the return value will be
      appended with zeros accordingly.
    </p>
    <p>
      Unlike <code>Number.prototype.toFixed</code>, which returns
      exponential notation if a number is greater or equal to 10<sup>21</sup>,
      this method will always return normal notation.
    </p>
    <p>
      If <code>dp</code> is omitted or is undefined, the return value is
      simply the value in normal notation. This is also unlike
      <code>Number.prototype.toFixed</code>, which returns the value to zero
      decimal places.
    </p>
    <p>
      Throws if <code>dp</code> is invalid.
    </p>
    <pre>
x = 45.6
y = new Big(x)
x.toFixed()                // '46'
y.toFixed()                // '45.6'
y.toFixed(0)               // '46'
x.toFixed(3)               // '45.600'
y.toFixed(3)               // '45.600'</pre>



    <h5 id="toJSON">
      toJSON<code class='inset'>.toJSON() <i>&rArr; string</i></code>
    </h5>
    <p>As <a href='#toS'><code>toString</code></a>.</p>
    <pre>
x = new Big('177.7e+457')
y = new Big(235.4325)
z = new Big('0.0098074')
str = JSON.stringify( [x, y, z] )

JSON.parse(str, function (k, v) { return k === '' ? v : new Big(v) })
// Returns an array of three Big numbers.</pre>



    <h5 id="toP">
      toPrecision<code class='inset'>.toPrecision(sd) &rArr;
      <i>string</i></code>
    </h5>
    <p><code>sd</code>? : <i>number</i> : integer, 1 to 1e+6 inclusive</p>
    <p>
      Returns a string representing the value of this Big number to the
      specified number of <code>sd</code> significant digits.
    </p>
    <p>
      If the value of this Big number has more digits than is specified by
      <code>sd</code>, the return value will be rounded to <code>sd</code>
      significant digits using rounding mode
      <a href='#rm'><code>Big.RM</code></a>.
    </p>
    <p>
      If the value of this Big number has fewer digits than is specified by
      <code>sd</code>, the return value will be appended with zeros accordingly.
    </p>
    <p>
      If <code>sd</code> is less than the number of digits necessary to
      represent the integer part of the value in normal notation,
      exponential notation is used.
    </p>
    <p>
      If <code>sd</code> is omitted or is undefined, the return value is
      the same as <code>.toString()</code>.
    </p>
    <p>
      Throws if <code>sd</code> is invalid.
    </p>
    <pre>
x = 45.6
y = new Big(x)
x.toPrecision()            // '45.6'
y.toPrecision()            // '45.6'
x.toPrecision(1)           // '5e+1'
y.toPrecision(1)           // '5e+1'
x.toPrecision(5)           // '45.600'
y.toPrecision(5)           // '45.600'</pre>



    <h5 id="toN">
      toNumber<code class='inset'>.toNumber() <i>&rArr; number</i></code>
    </h5>
    <p>
      Returns a primitive number representing the value of this Big number.
    </p>
    <pre>
x = new Big('123.45')
x.toNumber()               // 123.45
y = new Big('1.0000000000000000001')
y.toNumber()               // 1
</pre>
    <p>
      If <a href='#strict'><code>Big.strict</code></a> is <code>true</code> an
      error will be thrown if <code>toNumber</code> is called on a Big number
      which cannot be converted to a primitive number without a loss of precision.
    </p>



    <h5 id="toS">
      toString<code class='inset'>.toString() <i>&rArr; string</i></code>
    </h5>
    <p>
      Returns a string representing the value of this Big number.
    </p>
     <p>
      If this Big number has a positive exponent that is equal to or greater
      than 21, or a negative exponent equal to or less than -7, exponential
      notation is returned.
    </p>
    <p>
      The point at which <code>toString</code> returns exponential rather than
      normal notation can be adjusted by changing the value of
      <a href='#epos'><code>Big.PE</code></a> and
      <a href='#eneg'><code>Big.NE</code></a>. By default, Big numbers
      correspond to JavaScript's number type in this regard.
    </p>
    <pre>
x = new Big('9.99e+20')
x.toString()               // '999000000000000000000'
y = new Big('1E21')
y.toString()               // '1e+21'
</pre>



    <h5 id="valueOf">
      valueOf<code class='inset'>.valueOf() <i>&rArr; string</i></code>
    </h5>
    <p>
      As <a href='#toS'><code>toString</code></a> except the minus sign is
      included for negative zero.
    </p>
    <pre>
x = new Big(-0)
x.valueOf()                 // '-0'
x.toString()                // '0'</pre>
    <p>
      To prevent accidental usage of Big numbers with arithmetic operators,
      if <a href='#strict'><code>Big.strict</code></a> is <code>true</code> any
      explicit or implicit calls to <code>valueOf</code> will result in an error.
    </p>



    <h4 id="instance-properties">Properties</h4>
    <p>
      A Big number is an object with three properties:
    </p>
    <table>
      <tr>
        <th>Property</th>
        <th>Description</th>
        <th>Type</th>
        <th>Value</th>
      </tr>
      <tr>
        <td class='centre' id='coefficient'><b>c</b></td>
        <td>coefficient<sup>*</sup></td>
        <td><i>number</i><code>[]</code></td>
        <td> Array of single digits</td>
      </tr>
      <tr>
        <td class='centre' id='exponent'><b>e</b></td>
        <td>exponent</td>
        <td><i>number</i></td>
        <td>Integer, -1e+6 to 1e+6 inclusive</td>
      </tr>
      <tr>
        <td class='centre' id='sign'><b>s</b></td>
        <td>sign</td>
        <td><i>number</i></td>
        <td>-1 or 1</td>
      </tr>
    </table>
    <p><sup>*</sup>significand</p>
    <p>
      The value of a Big number is stored in a normalised decimal floating point
      format which corresponds to the value's <code>toExponential</code> form,
      with the decimal point to be positioned after the most significant
      (left-most) digit of the coefficient.
    </p>
    <p>
      Note that, as with JavaScript numbers, the original exponent and
      fractional trailing zeros are not preserved.
    </p>
    <pre>x = new Big(0.123)                 // '0.123'
x.toExponential()                  // '1.23e-1'
x.c                                // '1,2,3'
x.e                                // -1
x.s                                // 1

y = new Number(-123.4567000e+2)    // '-12345.67'
y.toExponential()                  // '-1.234567e+4'
z = new Big('-123.4567000e+2')     // '-12345.67'
z.toExponential()                  // '-1.234567e+4'
z.c                                // '1,2,3,4,5,6,7'
z.e                                // 4
z.s                                // -1</pre>


    <p>
      A Big number is mutable in the sense that the value of its properties can
      be changed.<br />
      For example, to rapidly shift a value by a power of 10:
    </p>
    <pre>
x = new Big('1234.000')    // '1234'
x.toExponential()          // '1.234e+3'
x.c                        // '1,2,3,4'
x.e                        // 3

x.e = -5
x                          // '0.00001234'</pre>
    <p>
      If changing the coefficient array directly, which is not recommended, be
      careful to avoid leading or trailing zeros (unless zero itself is being
      represented).
    </p>
    <p>
      Minus zero is a valid Big number value, but like JavaScript numbers the
      minus sign is not shown by <code>toString</code>.
    </p>
    <pre>
x = new Number(-0)         // 0
1 / x == -Infinity         // true

y = new Big(-0)            // '0'
y.c                        // '0'    [0].toString()
y.e                        // 0
y.s                        // -1</pre>



    <h4 id='Errors'>Errors</h4>
    <p>
      The errors that are thrown are instances of <code>Error</code>.<br />
      The <code>message</code> of the errors always begins with
      <code class='error'>[big.js]</code>, for example:
    </p>
    <pre>Error: [big.js] Invalid value</pre>
    <table>
      <tr>
        <th>Method(s)</th>
        <th>Error message</th>
        <th>Thrown on/when</th>
      </tr>
      <tr>
        <td rowspan=2>
          <code>
            Big<br />cmp<br />div<br />eq gt gte lt lte<br />minus<br />mod
            <br />plus<br />times
          </code>
        </td>
        <td>Invalid value</td>
        <td>Invalid value</td>
      </tr>
      <tr>
        <td>String expected</td>
        <td><code>Big.strict</code> is <code>true</code></td>
      </tr>
      <tr>
        <td rowspan=3><code>div</code></td>
        <td>Division by zero</td>
        <td>Division by zero</td>
      </tr>
      <tr>
        <td>Invalid decimal places</td>
        <td>Invalid <code>Big.DP</code></td>
      </tr>
      <tr>
        <td>Invalid rounding mode</td>
        <td>Invalid <code>Big.RM</code></td>
      </tr>
      <tr>
        <td><code>mod</code></td>
        <td>Division by zero</td>
        <td>Modulo zero</td>
      </tr>
      <tr>
        <td rowspan=3><code>pow</code></td>
        <td>Invalid exponent</td>
        <td>Invalid exponent</td>
      </tr>
      <tr>
        <td>Invalid decimal places</td>
        <td>Invalid <code>Big.DP</code></td>
      </tr>
      <tr>
        <td>Invalid rounding mode</td>
        <td>Invalid <code>Big.RM</code></td>
      </tr>
      <tr>
        <td rowspan=2><code>prec</code></td>
        <td>Invalid precision</td>
        <td>Invalid <code>sd</code></td>
      </tr>
      <tr>
        <td>Invalid rounding mode</i></td>
        <td>Invalid <code>rm</code>/<code>Big.RM</code></td>
      </tr>
      <tr>
        <td rowspan=2><code>round</code></td>
        <td>Invalid decimal places</td>
        <td>Invalid <code>dp</code></td>
      </tr>
      <tr>
        <td>Invalid rounding mode</i></td>
        <td>Invalid <code>rm</code>/<code>Big.RM</code></td>
      </tr>
      <tr>
        <td rowspan=3><code>sqrt</code></td>
        <td>No square root</td>
        <td>Negative number</td>
      </tr>
      <tr>
        <td>Invalid decimal places</td>
        <td>Invalid <code>Big.DP</code></td>
      </tr>
      <tr>
        <td>Invalid rounding mode</td>
        <td>Invalid <code>Big.RM</code></td>
      </tr>
      <tr>
        <td rowspan=2><code>toExponential</code></td>
        <td>Invalid decimal places</td>
        <td>Invalid <code>dp</code></td>
      </tr>
      <tr>
        <td>Invalid rounding mode</td>
        <td>Invalid <code>Big.RM</code></td>
      </tr>
      <tr>
        <td rowspan=2><code>toFixed</code></td>
        <td>Invalid decimal places</td>
        <td>Invalid <code>dp</code></td>
      </tr>
      <tr>
        <td>Invalid rounding mode</td>
        <td>Invalid <code>Big.RM</code></td>
      </tr>
      <tr>
        <td><code>toNumber</code></td>
        <td>Imprecise conversion</td>
        <td><code>Big.strict</code> is <code>true</code></td>
      </tr>
      <tr>
        <td rowspan=2><code>toPrecision</code></td>
        <td>Invalid precision</td>
        <td>Invalid <code>sd</code></td>
      </tr>
      <tr>
        <td>Invalid rounding mode</td>
        <td>Invalid <code>Big.RM</code></td>
      </tr>
      <tr>
        <td><code>valueOf</code></td>
        <td>valueOf disallowed</td>
        <td><code>Big.strict</code> is <code>true</code></td>
      </tr>
    </table>



    <h4 id='faq'>FAQ</h4>
    <h6>How can I convert a Big number to a primitive JavaScript number?</h6>
    <p>See <a href='#toN'><code>toNumber</code></a>.</p>


    <h6>
      How can I round a Big number to a specified number of significant digits?
    </h6>
    <p>See <a href='#prec'><code>prec</code></a>.</p>


    <h6>
      How can I set the decimal places and/or rounding mode for just one
      operation?
    </h6>
    <p>
      This library uses a global configuration for the decimal places and
      rounding mode used by division operations, so it is just a matter of
      altering this as required.
    </p>
    <pre>
Big.DP = 10
y = x.sqrt()
Big.DP = 0
Big.RM = 1
z = x.div(3)
</pre>
    <p>
      There is also the ability to create separate Big number constructors each
      with their own particular <code>DP</code> and <code>RM</code> settings.
      See below.
    </p>
    <p>
      Finally, there is the option of safely redefining the relevant prototype
      method as required. For example, the following would enable a decimal
      places and rounding mode to be passed to the <code>div</code> method.
    </p>
    <pre>
Big.prototype.div = (function () {
  const div = Big.prototype.div;
  return function (n, dp, rm) {
    const Big = this.constructor;
    const DP = Big.DP;
    const RM = Big.RM;
    if (dp != undefined) Big.DP = dp;
    if (rm != undefined) Big.RM = rm;
    let result = div.call(this, n);
    Big.DP = DP;
    Big.RM = RM;
    return result;
  }
})();

var dp = 10;
var round_up = 2;
x = x.div(y, dp, round_up);
</pre>


    <h6 id="multiple">
      How can I simultaneously use different decimal places and/or rounding mode
      settings for different Big numbers?
    </h6>
    <p>
      Multiple Big number constructors can be created each with their own particular
      <code>DP</code> and <code>RM</code> settings which apply to all Big numbers
      created from it.
    </p>
    <p>
      As shown below, an additional Big number constructor is created by calling
      an existing Big number constructor without using <code>new</code> and
      without any argument.
    </p>
    <pre>
Big10 = Big();

Big.DP = 3;
Big10.DP = 10;

x = Big(5);
y = Big10(5);

x.div(3)     // 1.667
y.div(3)     // 1.6666666667
</pre>
    <p>
      Big numbers created by different constructors can be used together in
      operations, and it is the <code>DP</code> and <code>RM</code> setting of
      the Big number that an operation is called upon that will apply.
    </p>
    <p>
      In the interest of memory efficiency, all Big number constructors share
      the same <code>prototype</code> object, so while the <code>DP</code> and
      <code>RM</code> (and any other <i>own</i> properties) of a constructor are
      isolated and untouchable by another, its prototype methods are not.
    </p>


    <h6>Why are trailing fractional zeros removed from Big numbers?</h6>
    <p>
      Many arbitrary-precision libraries retain trailing fractional zeros as
      they can indicate the precision of a value. This can be useful but the
      results of arithmetic operations can be misleading.
    </p>
    <pre>
// Java's BigDecimal
x = new BigDecimal("1.0")
y = new BigDecimal("1.1000")
z = x.add(y)                      // 2.1000

x = new BigDecimal("1.20")
y = new BigDecimal("3.45000")
z = x.multiply(y)                 // 4.1400000
</pre>
    <p>
      To specify the precision of a value is to imply that the value lies
      within a certain range.
    </p>
    <p>
      In the first example, <code>x</code> has a value of 1.0. The trailing zero
      shows the precision of the value, implying that the value is in the range
      0.95 to 1.05. Similarly, the precision indicated by the trailing zeros of
      <code>y</code> indicates that the value is in the range 1.09995 to
      1.10005. If we add the two lowest values in the ranges we get 0.95 +
      1.09995 = 2.04995 and if we add the two highest values we get 1.05 +
      1.10005 = 2.15005, so the range of the result of the addition implied by
      the precision of its operands is 2.04995 to 2.15005. The result given by
      BigDecimal of 2.1000 however, indicates that the value is in the range
      2.09995 to 2.10005 and therefore the precision implied by its trailing
      zeros is misleading.
    </p>
    <p>
      In the second example, the true range is 4.122744 to 4.157256 yet the
      BigDecimal answer of 4.1400000 indicates a range of 4.13999995 to
      4.14000005. Again, the precision implied by the trailing zeros is
      misleading.
    </p>
    <p>
      This library, like binary floating-point and most calculators, does not
      retain trailing fractional zeros.<br />
      Instead, the <code>toExponential</code>, <code>toFixed</code> and
      <code>toPrecision</code> methods enable trailing zeros to be added if and
      when required.
    </p>
    <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
    <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>

  </div>

  <script>
  /* big.js v6.0.3 https://github.com/MikeMcl/big.js/LICENCE.md */
  /* terser big.js -c -m -o big.min.js */
  !function(r){"use strict";var e,t=1e6,n=1e6,i="[big.js] ",o=i+"Invalid ",s=o+"decimal places",c=i+"Division by zero",f={},u=void 0,h=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;function l(r,t,n,i){var o=r.c;if(n===u&&(n=e.RM),0!==n&&1!==n&&2!==n&&3!==n)throw Error("[big.js] Invalid rounding mode");if(t<1)i=3===n&&(i||!!o[0])||0===t&&(1===n&&o[0]>=5||2===n&&(o[0]>5||5===o[0]&&(i||o[1]!==u))),o.length=1,i?(r.e=r.e-t+1,o[0]=1):o[0]=r.e=0;else if(t<o.length){if(i=1===n&&o[t]>=5||2===n&&(o[t]>5||5===o[t]&&(i||o[t+1]!==u||1&o[t-1]))||3===n&&(i||!!o[0]),o.length=t--,i)for(;++o[t]>9;)o[t]=0,t--||(++r.e,o.unshift(1));for(t=o.length;!o[--t];)o.pop()}return r}function a(r,e,t){var n=r.e,i=r.c.join(""),o=i.length;if(e)i=i.charAt(0)+(o>1?"."+i.slice(1):"")+(n<0?"e":"e+")+n;else if(n<0){for(;++n;)i="0"+i;i="0."+i}else if(n>0)if(++n>o)for(n-=o;n--;)i+="0";else n<o&&(i=i.slice(0,n)+"."+i.slice(n));else o>1&&(i=i.charAt(0)+"."+i.slice(1));return r.s<0&&t?"-"+i:i}f.abs=function(){var r=new this.constructor(this);return r.s=1,r},f.cmp=function(r){var e,t=this,n=t.c,i=(r=new t.constructor(r)).c,o=t.s,s=r.s,c=t.e,f=r.e;if(!n[0]||!i[0])return n[0]?o:i[0]?-s:0;if(o!=s)return o;if(e=o<0,c!=f)return c>f^e?1:-1;for(s=(c=n.length)<(f=i.length)?c:f,o=-1;++o<s;)if(n[o]!=i[o])return n[o]>i[o]^e?1:-1;return c==f?0:c>f^e?1:-1},f.div=function(r){var e=this,n=e.constructor,i=e.c,o=(r=new n(r)).c,f=e.s==r.s?1:-1,h=n.DP;if(h!==~~h||h<0||h>t)throw Error(s);if(!o[0])throw Error(c);if(!i[0])return r.s=f,r.c=[r.e=0],r;var a,p,g,w,v,d=o.slice(),m=a=o.length,E=i.length,b=i.slice(0,a),P=b.length,M=r,x=M.c=[],D=0,N=h+(M.e=e.e-r.e)+1;for(M.s=f,f=N<0?0:N,d.unshift(0);P++<a;)b.push(0);do{for(g=0;g<10;g++){if(a!=(P=b.length))w=a>P?1:-1;else for(v=-1,w=0;++v<a;)if(o[v]!=b[v]){w=o[v]>b[v]?1:-1;break}if(!(w<0))break;for(p=P==a?o:d;P;){if(b[--P]<p[P]){for(v=P;v&&!b[--v];)b[v]=9;--b[v],b[P]+=10}b[P]-=p[P]}for(;!b[0];)b.shift()}x[D++]=w?g:++g,b[0]&&w?b[P]=i[m]||0:b=[i[m]]}while((m++<E||b[0]!==u)&&f--);return x[0]||1==D||(x.shift(),M.e--,N--),D>N&&l(M,N,n.RM,b[0]!==u),M},f.eq=function(r){return 0===this.cmp(r)},f.gt=function(r){return this.cmp(r)>0},f.gte=function(r){return this.cmp(r)>-1},f.lt=function(r){return this.cmp(r)<0},f.lte=function(r){return this.cmp(r)<1},f.minus=f.sub=function(r){var e,t,n,i,o=this,s=o.constructor,c=o.s,f=(r=new s(r)).s;if(c!=f)return r.s=-f,o.plus(r);var u=o.c.slice(),h=o.e,l=r.c,a=r.e;if(!u[0]||!l[0])return l[0]?r.s=-f:u[0]?r=new s(o):r.s=1,r;if(c=h-a){for((i=c<0)?(c=-c,n=u):(a=h,n=l),n.reverse(),f=c;f--;)n.push(0);n.reverse()}else for(t=((i=u.length<l.length)?u:l).length,c=f=0;f<t;f++)if(u[f]!=l[f]){i=u[f]<l[f];break}if(i&&(n=u,u=l,l=n,r.s=-r.s),(f=(t=l.length)-(e=u.length))>0)for(;f--;)u[e++]=0;for(f=e;t>c;){if(u[--t]<l[t]){for(e=t;e&&!u[--e];)u[e]=9;--u[e],u[t]+=10}u[t]-=l[t]}for(;0===u[--f];)u.pop();for(;0===u[0];)u.shift(),--a;return u[0]||(r.s=1,u=[a=0]),r.c=u,r.e=a,r},f.mod=function(r){var e,t=this,n=t.constructor,i=t.s,o=(r=new n(r)).s;if(!r.c[0])throw Error(c);return t.s=r.s=1,e=1==r.cmp(t),t.s=i,r.s=o,e?new n(t):(i=n.DP,o=n.RM,n.DP=n.RM=0,t=t.div(r),n.DP=i,n.RM=o,this.minus(t.times(r)))},f.plus=f.add=function(r){var e,t,n,i=this,o=i.constructor;if(r=new o(r),i.s!=r.s)return r.s=-r.s,i.minus(r);var s=i.e,c=i.c,f=r.e,u=r.c;if(!c[0]||!u[0])return u[0]||(c[0]?r=new o(i):r.s=i.s),r;if(c=c.slice(),e=s-f){for(e>0?(f=s,n=u):(e=-e,n=c),n.reverse();e--;)n.push(0);n.reverse()}for(c.length-u.length<0&&(n=u,u=c,c=n),e=u.length,t=0;e;c[e]%=10)t=(c[--e]=c[e]+u[e]+t)/10|0;for(t&&(c.unshift(t),++f),e=c.length;0===c[--e];)c.pop();return r.c=c,r.e=f,r},f.pow=function(r){var e=this,t=new e.constructor("1"),i=t,s=r<0;if(r!==~~r||r<-1e6||r>n)throw Error(o+"exponent");for(s&&(r=-r);1&r&&(i=i.times(e)),r>>=1;)e=e.times(e);return s?t.div(i):i},f.prec=function(r,e){if(r!==~~r||r<1||r>t)throw Error(o+"precision");return l(new this.constructor(this),r,e)},f.round=function(r,e){if(r===u)r=0;else if(r!==~~r||r<-t||r>t)throw Error(s);return l(new this.constructor(this),r+this.e+1,e)},f.sqrt=function(){var r,e,t,n=this,o=n.constructor,s=n.s,c=n.e,f=new o("0.5");if(!n.c[0])return new o(n);if(s<0)throw Error(i+"No square root");0===(s=Math.sqrt(n+""))||s===1/0?((e=n.c.join("")).length+c&1||(e+="0"),c=((c+1)/2|0)-(c<0||1&c),r=new o(((s=Math.sqrt(e))==1/0?"5e":(s=s.toExponential()).slice(0,s.indexOf("e")+1))+c)):r=new o(s+""),c=r.e+(o.DP+=4);do{t=r,r=f.times(t.plus(n.div(t)))}while(t.c.slice(0,c).join("")!==r.c.slice(0,c).join(""));return l(r,(o.DP-=4)+r.e+1,o.RM)},f.times=f.mul=function(r){var e,t=this,n=t.constructor,i=t.c,o=(r=new n(r)).c,s=i.length,c=o.length,f=t.e,u=r.e;if(r.s=t.s==r.s?1:-1,!i[0]||!o[0])return r.c=[r.e=0],r;for(r.e=f+u,s<c&&(e=i,i=o,o=e,u=s,s=c,c=u),e=new Array(u=s+c);u--;)e[u]=0;for(f=c;f--;){for(c=0,u=s+f;u>f;)c=e[u]+o[f]*i[u-f-1]+c,e[u--]=c%10,c=c/10|0;e[u]=c}for(c?++r.e:e.shift(),f=e.length;!e[--f];)e.pop();return r.c=e,r},f.toExponential=function(r,e){var n=this,i=n.c[0];if(r!==u){if(r!==~~r||r<0||r>t)throw Error(s);for(n=l(new n.constructor(n),++r,e);n.c.length<r;)n.c.push(0)}return a(n,!0,!!i)},f.toFixed=function(r,e){var n=this,i=n.c[0];if(r!==u){if(r!==~~r||r<0||r>t)throw Error(s);for(r=r+(n=l(new n.constructor(n),r+n.e+1,e)).e+1;n.c.length<r;)n.c.push(0)}return a(n,!1,!!i)},f.toJSON=f.toString=function(){var r=this,e=r.constructor;return a(r,r.e<=e.NE||r.e>=e.PE,!!r.c[0])},f.toNumber=function(){var r=Number(a(this,!0,!0));if(!0===this.constructor.strict&&!this.eq(r.toString()))throw Error(i+"Imprecise conversion");return r},f.toPrecision=function(r,e){var n=this,i=n.constructor,s=n.c[0];if(r!==u){if(r!==~~r||r<1||r>t)throw Error(o+"precision");for(n=l(new i(n),r,e);n.c.length<r;)n.c.push(0)}return a(n,r<=n.e||n.e<=i.NE||n.e>=i.PE,!!s)},f.valueOf=function(){var r=this,e=r.constructor;if(!0===e.strict)throw Error(i+"valueOf disallowed");return a(r,r.e<=e.NE||r.e>=e.PE,!0)},(e=function r(){function e(t){var n=this;if(!(n instanceof e))return t===u?r():new e(t);if(t instanceof e)n.s=t.s,n.e=t.e,n.c=t.c.slice();else{if("string"!=typeof t){if(!0===e.strict)throw TypeError(o+"number");t=0===t&&1/t<0?"-0":String(t)}!function(r,e){var t,n,i;if(!h.test(e))throw Error(o+"number");r.s="-"==e.charAt(0)?(e=e.slice(1),-1):1,(t=e.indexOf("."))>-1&&(e=e.replace(".",""));(n=e.search(/e/i))>0?(t<0&&(t=n),t+=+e.slice(n+1),e=e.substring(0,n)):t<0&&(t=e.length);for(i=e.length,n=0;n<i&&"0"==e.charAt(n);)++n;if(n==i)r.c=[r.e=0];else{for(;i>0&&"0"==e.charAt(--i););for(r.e=t-n-1,r.c=[],t=0;n<=i;)r.c[t++]=+e.charAt(n++)}}(n,t)}n.constructor=e}return e.prototype=f,e.DP=20,e.RM=1,e.NE=-7,e.PE=21,e.strict=false,e}()).default=e.Big=e,"function"==typeof define&&define.amd?define((function(){return e})):"undefined"!=typeof module&&module.exports?module.exports=e:r.Big=e}(this);
  </script>

</body>
</html>