Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/postfix_evaluator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,5 +94,5 @@ export function postfixEval(arr: ReturnType<typeof toPostfix>, Constants: Consta
throw new Error('Uncaught Syntax error')
}
// @ts-ignore
return parseFloat(stack[0].value.toFixed(15))
return stack[0].value
}
6 changes: 3 additions & 3 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ describe('Testing Unit', function () {
assert.equal(mexp.eval('2'), 2)
})
it('checks a math function', function () {
assert.equal(mexp.eval('tan(180)'), 0)
assert.equal(parseFloat(mexp.eval('tan(180)').toFixed(15)), 0)
})
it('checks a parenthesis less function', function () {
assert.equal(mexp.eval('sin180'), 0)
assert.equal(parseFloat(mexp.eval('sin180').toFixed(15)), 0)
})
it('checks a parenthesis less function with multiplication', function () {
assert.equal(mexp.eval('0sin180'), 0)
Expand Down Expand Up @@ -160,7 +160,7 @@ describe('Testing Unit', function () {
)
})
it('tan(40+5)', function () {
assert.equal(mexp.eval('tan(40+5)'), '1')
assert.equal(parseFloat(mexp.eval('tan(40+5)').toFixed(15)), 1)
})
it('checks when a 0 is missing in a decimal number', function () {
assert.equal(mexp.eval('5*.8'), '4')
Expand Down