mirror of
https://github.com/josdejong/mathjs.git
synced 2026-01-18 14:59:29 +00:00
Added some additional tests for engineering format
This commit is contained in:
parent
0a6aded52a
commit
ce77993689
@ -121,6 +121,22 @@ describe('format', function () {
|
||||
assert.strictEqual(math.format(1.24, { notation: 'engineering', precision: 3 }), '1.24e+0')
|
||||
|
||||
// less significant figures than precision, need to add zeros
|
||||
assert.strictEqual(math.format(-1e12, { notation: 'engineering', precision: 3 }), '-1.00e+12')
|
||||
assert.strictEqual(math.format(-1e11, { notation: 'engineering', precision: 3 }), '-100e+9')
|
||||
assert.strictEqual(math.format(-1e10, { notation: 'engineering', precision: 3 }), '-10.0e+9')
|
||||
assert.strictEqual(math.format(-1e9, { notation: 'engineering', precision: 3 }), '-1.00e+9')
|
||||
assert.strictEqual(math.format(1e12, { notation: 'engineering', precision: 3 }), '1.00e+12')
|
||||
assert.strictEqual(math.format(1e11, { notation: 'engineering', precision: 3 }), '100e+9')
|
||||
assert.strictEqual(math.format(1e10, { notation: 'engineering', precision: 3 }), '10.0e+9')
|
||||
assert.strictEqual(math.format(1e9, { notation: 'engineering', precision: 3 }), '1.00e+9')
|
||||
assert.strictEqual(math.format(1e12, { notation: 'engineering', precision: 2 }), '1.0e+12')
|
||||
assert.strictEqual(math.format(1e11, { notation: 'engineering', precision: 2 }), '100e+9')
|
||||
assert.strictEqual(math.format(1e10, { notation: 'engineering', precision: 2 }), '10e+9')
|
||||
assert.strictEqual(math.format(1e9, { notation: 'engineering', precision: 2 }), '1.0e+9')
|
||||
assert.strictEqual(math.format(1e12, { notation: 'engineering', precision: 1 }), '1e+12')
|
||||
assert.strictEqual(math.format(1e11, { notation: 'engineering', precision: 1 }), '100e+9')
|
||||
assert.strictEqual(math.format(1e10, { notation: 'engineering', precision: 1 }), '10e+9')
|
||||
assert.strictEqual(math.format(1e9, { notation: 'engineering', precision: 1 }), '1e+9')
|
||||
assert.strictEqual(math.format(10e3, { notation: 'engineering', precision: 2 }), '10e+3')
|
||||
assert.strictEqual(math.format(10e3, { notation: 'engineering', precision: 1 }), '10e+3')
|
||||
assert.strictEqual(math.format(100e3, { notation: 'engineering', precision: 2 }), '100e+3')
|
||||
@ -132,6 +148,18 @@ describe('format', function () {
|
||||
assert.strictEqual(math.format(10e-3, { notation: 'engineering', precision: 2 }), '10e-3')
|
||||
assert.strictEqual(math.format(100e-3, { notation: 'engineering', precision: 2 }), '100e-3')
|
||||
assert.strictEqual(math.format(100e-3, { notation: 'engineering', precision: 1 }), '100e-3')
|
||||
assert.strictEqual(math.format(1e-3, { notation: 'engineering', precision: 1 }), '1e-3')
|
||||
assert.strictEqual(math.format(1e-4, { notation: 'engineering', precision: 1 }), '100e-6')
|
||||
assert.strictEqual(math.format(1e-5, { notation: 'engineering', precision: 1 }), '10e-6')
|
||||
assert.strictEqual(math.format(1e-6, { notation: 'engineering', precision: 1 }), '1e-6')
|
||||
assert.strictEqual(math.format(1e-3, { notation: 'engineering', precision: 3 }), '1.00e-3')
|
||||
assert.strictEqual(math.format(1e-4, { notation: 'engineering', precision: 3 }), '100e-6')
|
||||
assert.strictEqual(math.format(1e-5, { notation: 'engineering', precision: 3 }), '10.0e-6')
|
||||
assert.strictEqual(math.format(1e-6, { notation: 'engineering', precision: 3 }), '1.00e-6')
|
||||
assert.strictEqual(math.format(-1e-3, { notation: 'engineering', precision: 3 }), '-1.00e-3')
|
||||
assert.strictEqual(math.format(-1e-4, { notation: 'engineering', precision: 3 }), '-100e-6')
|
||||
assert.strictEqual(math.format(-1e-5, { notation: 'engineering', precision: 3 }), '-10.0e-6')
|
||||
assert.strictEqual(math.format(-1e-6, { notation: 'engineering', precision: 3 }), '-1.00e-6')
|
||||
})
|
||||
})
|
||||
|
||||
@ -216,6 +244,22 @@ describe('format', function () {
|
||||
assert.strictEqual(math.format(bignumber(1.24), { notation: 'engineering', precision: 3 }), '1.24e+0')
|
||||
|
||||
// less significant figures than precision, need to add zeros
|
||||
assert.strictEqual(math.format(bignumber(-1e12), { notation: 'engineering', precision: 3 }), '-1.00e+12')
|
||||
assert.strictEqual(math.format(bignumber(-1e11), { notation: 'engineering', precision: 3 }), '-100e+9')
|
||||
assert.strictEqual(math.format(bignumber(-1e10), { notation: 'engineering', precision: 3 }), '-10.0e+9')
|
||||
assert.strictEqual(math.format(bignumber(-1e9), { notation: 'engineering', precision: 3 }), '-1.00e+9')
|
||||
assert.strictEqual(math.format(bignumber(1e12), { notation: 'engineering', precision: 3 }), '1.00e+12')
|
||||
assert.strictEqual(math.format(bignumber(1e11), { notation: 'engineering', precision: 3 }), '100e+9')
|
||||
assert.strictEqual(math.format(bignumber(1e10), { notation: 'engineering', precision: 3 }), '10.0e+9')
|
||||
assert.strictEqual(math.format(bignumber(1e9), { notation: 'engineering', precision: 3 }), '1.00e+9')
|
||||
assert.strictEqual(math.format(bignumber(1e12), { notation: 'engineering', precision: 2 }), '1.0e+12')
|
||||
assert.strictEqual(math.format(bignumber(1e11), { notation: 'engineering', precision: 2 }), '100e+9')
|
||||
assert.strictEqual(math.format(bignumber(1e10), { notation: 'engineering', precision: 2 }), '10e+9')
|
||||
assert.strictEqual(math.format(bignumber(1e9), { notation: 'engineering', precision: 2 }), '1.0e+9')
|
||||
assert.strictEqual(math.format(bignumber(1e12), { notation: 'engineering', precision: 1 }), '1e+12')
|
||||
assert.strictEqual(math.format(bignumber(1e11), { notation: 'engineering', precision: 1 }), '100e+9')
|
||||
assert.strictEqual(math.format(bignumber(1e10), { notation: 'engineering', precision: 1 }), '10e+9')
|
||||
assert.strictEqual(math.format(bignumber(1e9), { notation: 'engineering', precision: 1 }), '1e+9')
|
||||
assert.strictEqual(math.format(bignumber(10e3), { notation: 'engineering', precision: 2 }), '10e+3')
|
||||
assert.strictEqual(math.format(bignumber(10e3), { notation: 'engineering', precision: 1 }), '10e+3')
|
||||
assert.strictEqual(math.format(bignumber(100e3), { notation: 'engineering', precision: 2 }), '100e+3')
|
||||
@ -227,6 +271,26 @@ describe('format', function () {
|
||||
assert.strictEqual(math.format(bignumber(10e-3), { notation: 'engineering', precision: 2 }), '10e-3')
|
||||
assert.strictEqual(math.format(bignumber(100e-3), { notation: 'engineering', precision: 2 }), '100e-3')
|
||||
assert.strictEqual(math.format(bignumber(100e-3), { notation: 'engineering', precision: 1 }), '100e-3')
|
||||
assert.strictEqual(math.format(bignumber(1e-3), { notation: 'engineering', precision: 1 }), '1e-3')
|
||||
assert.strictEqual(math.format(bignumber(1e-4), { notation: 'engineering', precision: 1 }), '100e-6')
|
||||
assert.strictEqual(math.format(bignumber(1e-5), { notation: 'engineering', precision: 1 }), '10e-6')
|
||||
assert.strictEqual(math.format(bignumber(1e-6), { notation: 'engineering', precision: 1 }), '1e-6')
|
||||
assert.strictEqual(math.format(bignumber(1e-3), { notation: 'engineering', precision: 3 }), '1.00e-3')
|
||||
assert.strictEqual(math.format(bignumber(1e-4), { notation: 'engineering', precision: 3 }), '100e-6')
|
||||
assert.strictEqual(math.format(bignumber(1e-5), { notation: 'engineering', precision: 3 }), '10.0e-6')
|
||||
assert.strictEqual(math.format(bignumber(1e-6), { notation: 'engineering', precision: 3 }), '1.00e-6')
|
||||
assert.strictEqual(math.format(bignumber(-1e-3), { notation: 'engineering', precision: 3 }), '-1.00e-3')
|
||||
assert.strictEqual(math.format(bignumber(-1e-4), { notation: 'engineering', precision: 3 }), '-100e-6')
|
||||
assert.strictEqual(math.format(bignumber(-1e-5), { notation: 'engineering', precision: 3 }), '-10.0e-6')
|
||||
assert.strictEqual(math.format(bignumber(-1e-6), { notation: 'engineering', precision: 3 }), '-1.00e-6')
|
||||
assert.strictEqual(math.format(bignumber('12345600000000'), { notation: 'engineering', precision: 3 }), '12.3e+12')
|
||||
assert.strictEqual(math.format(bignumber('12345600000000'), { notation: 'engineering', precision: 16 }), '12.34560000000000e+12')
|
||||
assert.strictEqual(math.format(bignumber('12345678901234.56789'), { notation: 'engineering', precision: 3 }), '12.3e+12')
|
||||
assert.strictEqual(math.format(bignumber('12345678901234.56789'), { notation: 'engineering', precision: 16 }), '12.34567890123457e+12')
|
||||
assert.strictEqual(math.format(bignumber('0.000000000000123456'), { notation: 'engineering', precision: 3 }), '123e-15')
|
||||
assert.strictEqual(math.format(bignumber('0.000000000000123456'), { notation: 'engineering', precision: 16 }), '123.4560000000000e-15')
|
||||
assert.strictEqual(math.format(bignumber('0.0000000000001234567890123456789'), { notation: 'engineering', precision: 3 }), '123e-15')
|
||||
assert.strictEqual(math.format(bignumber('0.0000000000001234567890123456789'), { notation: 'engineering', precision: 16 }), '123.4567890123457e-15')
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user