File tree Expand file tree Collapse file tree 5 files changed +35
-1
lines changed
Expand file tree Collapse file tree 5 files changed +35
-1
lines changed Original file line number Diff line number Diff line change 629629
630630 return this . minus ( x . times ( y ) ) ;
631631 } ;
632+
633+
634+ /*
635+ * Return a new Big whose value is the value of this Big negated.
636+ */
637+ P . neg = function ( ) {
638+ var x = new this . constructor ( this ) ;
639+ x . s = - x . s ;
640+ return x ;
641+ } ;
632642
633643
634644 /*
Original file line number Diff line number Diff line change @@ -628,6 +628,16 @@ P.mod = function (y) {
628628} ;
629629
630630
631+ /*
632+ * Return a new Big whose value is the value of this Big negated.
633+ */
634+ P . neg = function ( ) {
635+ var x = new this . constructor ( this ) ;
636+ x . s = - x . s ;
637+ return x ;
638+ } ;
639+
640+
631641/*
632642 * Return a new Big whose value is the value of this Big plus the value of Big y.
633643 */
Original file line number Diff line number Diff line change 103103 < li > < a href ="#lte " > lte</ a > </ li >
104104 < li > < a href ="#minus " > minus</ a > </ li >
105105 < li > < a href ="#mod " > mod</ a > </ li >
106+ < li > < a href ="#neg " > neg</ a > </ li >
106107 < li > < a href ="#plus " > plus</ a > </ li >
107108 < li > < a href ="#pow " > pow</ a > </ li >
108109 < li > < a href ="#prec " > prec</ a > </ li >
@@ -207,7 +208,7 @@ <h5 id="big">
207208new Big('-735.0918e-430') // '-7.350918e-428'
208209Big(435.345) // '435.345'
209210new Big() // 'Error: [big.js] Invalid value'
210- Big() // No error, and a new Big constructor is returned
211+ Big2 = Big() // No error, and a new Big constructor is returned
211212 </ pre >
212213
213214
@@ -580,6 +581,17 @@ <h5 id="mod">mod<code class='inset'>.mod(n) <i>⇒ Big</i></code></h5>
580581
581582
582583
584+ < h5 id ="neg "> neg< code class ='inset '> .neg() < i > ⇒ Big</ i > </ code > </ h5 >
585+ < p >
586+ Returns a Big number whose value is the value of this Big number negated.
587+ </ p >
588+ < pre >
589+ x = new Big(0.3)
590+ x.neg() // '-0.3'
591+ x.neg().neg() // '0.3'</ pre >
592+
593+
594+
583595 < h5 id ="plus ">
584596 plus< code class ='inset '> .plus(n) < i > ⇒ Big</ i > </ code >
585597 </ h5 >
Original file line number Diff line number Diff line change 1313 <!-- <script src='../methods/div.js'></script> -->
1414 <!-- <script src='../methods/minus.js'></script> -->
1515 <!-- <script src='../methods/mod.js'></script> -->
16+ <!-- <script src='../methods/neg.js'></script> -->
1617 <!-- <script src='../methods/plus.js'></script> -->
1718 <!-- <script src='../methods/pow.js'></script> -->
1819 <!-- <script src='../methods/prec.js'></script> -->
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ console.log( '\n Testing big.js\n' );
1010 'div' ,
1111 'minus' ,
1212 'mod' ,
13+ 'neg' ,
1314 'plus' ,
1415 'pow' ,
1516 'prec' ,
You can’t perform that action at this time.
0 commit comments