@@ -119,6 +119,19 @@ describe('format', function () {
119119 assert . strictEqual ( math . format ( 0.000124 , { notation : 'engineering' , precision : 4 } ) , '124.0e-6' )
120120 assert . strictEqual ( math . format ( 0.000124 , { notation : 'engineering' , precision : 3 } ) , '124e-6' )
121121 assert . strictEqual ( math . format ( 1.24 , { notation : 'engineering' , precision : 3 } ) , '1.24e+0' )
122+
123+ // less significant figures than precision, need to add zeros
124+ assert . strictEqual ( math . format ( 10e3 , { notation : 'engineering' , precision : 2 } ) , '10e+3' )
125+ assert . strictEqual ( math . format ( 10e3 , { notation : 'engineering' , precision : 1 } ) , '10e+3' )
126+ assert . strictEqual ( math . format ( 100e3 , { notation : 'engineering' , precision : 2 } ) , '100e+3' )
127+ assert . strictEqual ( math . format ( 100e3 , { notation : 'engineering' , precision : 1 } ) , '100e+3' )
128+ assert . strictEqual ( math . format ( 100 , { notation : 'engineering' , precision : 2 } ) , '100e+0' )
129+ assert . strictEqual ( math . format ( 10 , { notation : 'engineering' , precision : 2 } ) , '10e+0' )
130+ assert . strictEqual ( math . format ( 10 , { notation : 'engineering' , precision : 1 } ) , '10e+0' )
131+ assert . strictEqual ( math . format ( 1 , { notation : 'engineering' , precision : 2 } ) , '1.0e+0' )
132+ assert . strictEqual ( math . format ( 10e-3 , { notation : 'engineering' , precision : 2 } ) , '10e-3' )
133+ assert . strictEqual ( math . format ( 100e-3 , { notation : 'engineering' , precision : 2 } ) , '100e-3' )
134+ assert . strictEqual ( math . format ( 100e-3 , { notation : 'engineering' , precision : 1 } ) , '100e-3' )
122135 } )
123136 } )
124137
@@ -201,6 +214,19 @@ describe('format', function () {
201214 assert . strictEqual ( math . format ( bignumber ( 0.000124 ) , { notation : 'engineering' , precision : 4 } ) , '124.0e-6' )
202215 assert . strictEqual ( math . format ( bignumber ( 0.000124 ) , { notation : 'engineering' , precision : 3 } ) , '124e-6' )
203216 assert . strictEqual ( math . format ( bignumber ( 1.24 ) , { notation : 'engineering' , precision : 3 } ) , '1.24e+0' )
217+
218+ // less significant figures than precision, need to add zeros
219+ assert . strictEqual ( math . format ( bignumber ( 10e3 ) , { notation : 'engineering' , precision : 2 } ) , '10e+3' )
220+ assert . strictEqual ( math . format ( bignumber ( 10e3 ) , { notation : 'engineering' , precision : 1 } ) , '10e+3' )
221+ assert . strictEqual ( math . format ( bignumber ( 100e3 ) , { notation : 'engineering' , precision : 2 } ) , '100e+3' )
222+ assert . strictEqual ( math . format ( bignumber ( 100e3 ) , { notation : 'engineering' , precision : 1 } ) , '100e+3' )
223+ assert . strictEqual ( math . format ( bignumber ( 100 ) , { notation : 'engineering' , precision : 2 } ) , '100e+0' )
224+ assert . strictEqual ( math . format ( bignumber ( 10 ) , { notation : 'engineering' , precision : 2 } ) , '10e+0' )
225+ assert . strictEqual ( math . format ( bignumber ( 10 ) , { notation : 'engineering' , precision : 1 } ) , '10e+0' )
226+ assert . strictEqual ( math . format ( bignumber ( 1 ) , { notation : 'engineering' , precision : 2 } ) , '1.0e+0' )
227+ assert . strictEqual ( math . format ( bignumber ( 10e-3 ) , { notation : 'engineering' , precision : 2 } ) , '10e-3' )
228+ assert . strictEqual ( math . format ( bignumber ( 100e-3 ) , { notation : 'engineering' , precision : 2 } ) , '100e-3' )
229+ assert . strictEqual ( math . format ( bignumber ( 100e-3 ) , { notation : 'engineering' , precision : 1 } ) , '100e-3' )
204230 } )
205231 } )
206232 } )
0 commit comments