Skip to content
This repository was archived by the owner on Jul 15, 2022. It is now read-only.

Commit d6a82d8

Browse files
author
Ankit G
committed
removed bug when 0 missing in decimal number
1 parent 4fbc496 commit d6a82d8

11 files changed

+1500
-1489
lines changed

.npmignore

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
bower.json
2-
node_modules
3-
.gitignore
4-
.npmignore
1+
bower.json
2+
node_modules
3+
.gitignore
4+
.npmignore
55
Gruntfile.js

Gruntfile.js

+40-40
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,41 @@
1-
var banner='/* \n * The MIT License (MIT)\n * \n * Copyright (c) Ankit G.\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the "Software"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:</p>\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */';
2-
module.exports = function(grunt) {
3-
// Project configuration.
4-
grunt.initConfig({
5-
pkg: grunt.file.readJSON('package.json'),
6-
jshint:{
7-
all:['src/*.js']
8-
},
9-
browserify: {
10-
standalone: {
11-
src: [ 'src/formula_evaluator.js' ],
12-
dest: 'dist/browser/<%= pkg.name %>.js',
13-
options: {
14-
browserifyOptions: {
15-
standalone: 'mexp'
16-
},
17-
banner: '/** <%= pkg.name %> version <%= pkg.version %>\n Dated:<%= grunt.template.today("yyyy-mm-dd") %> */\n'
18-
19-
}
20-
}
21-
},
22-
uglify:{
23-
options: {
24-
banner: banner+'\n/** <%= pkg.name %> version <%= pkg.version %>\n Dated:<%= grunt.template.today("yyyy-mm-dd") %> */\n'
25-
},
26-
dist: {
27-
src: 'dist/browser/<%= pkg.name %>.js',
28-
dest: 'dist/browser/<%= pkg.name %>.min.js'
29-
}
30-
}
31-
});
32-
33-
// Load the plugin that provides the "uglify" task.
34-
grunt.loadNpmTasks('grunt-contrib-uglify');
35-
grunt.loadNpmTasks('grunt-contrib-jshint');
36-
grunt.loadNpmTasks('grunt-browserify');
37-
38-
// Default task(s).
39-
grunt.registerTask('default', ['jshint','browserify','uglify']);
40-
1+
var banner='/* \n * The MIT License (MIT)\n * \n * Copyright (c) Ankit G.\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the "Software"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:</p>\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */';
2+
module.exports = function(grunt) {
3+
// Project configuration.
4+
grunt.initConfig({
5+
pkg: grunt.file.readJSON('package.json'),
6+
jshint:{
7+
all:['src/*.js']
8+
},
9+
browserify: {
10+
standalone: {
11+
src: [ 'src/formula_evaluator.js' ],
12+
dest: 'dist/browser/<%= pkg.name %>.js',
13+
options: {
14+
browserifyOptions: {
15+
standalone: 'mexp'
16+
},
17+
banner: '/** <%= pkg.name %> version <%= pkg.version %>\n Dated:<%= grunt.template.today("yyyy-mm-dd") %> */\n'
18+
19+
}
20+
}
21+
},
22+
uglify:{
23+
options: {
24+
banner: banner+'\n/** <%= pkg.name %> version <%= pkg.version %>\n Dated:<%= grunt.template.today("yyyy-mm-dd") %> */\n'
25+
},
26+
dist: {
27+
src: 'dist/browser/<%= pkg.name %>.js',
28+
dest: 'dist/browser/<%= pkg.name %>.min.js'
29+
}
30+
}
31+
});
32+
33+
// Load the plugin that provides the "uglify" task.
34+
grunt.loadNpmTasks('grunt-contrib-uglify');
35+
grunt.loadNpmTasks('grunt-contrib-jshint');
36+
grunt.loadNpmTasks('grunt-browserify');
37+
38+
// Default task(s).
39+
grunt.registerTask('default', ['jshint','browserify','uglify']);
40+
4141
};

LICENSE

+22-22
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
The MIT License (MIT)
2-
3-
Copyright (c) 2015 Ankit G.
4-
5-
Permission is hereby granted, free of charge, to any person obtaining a copy
6-
of this software and associated documentation files (the "Software"), to deal
7-
in the Software without restriction, including without limitation the rights
8-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9-
copies of the Software, and to permit persons to whom the Software is
10-
furnished to do so, subject to the following conditions:
11-
12-
The above copyright notice and this permission notice shall be included in all
13-
copies or substantial portions of the Software.
14-
15-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21-
SOFTWARE.
22-
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2015 Ankit G.
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
22+

README.md

+78-78
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,79 @@
1-
2-
3-
# Introduction
4-
An extremely efficient, flexible and amazing evaluator with a smart parser for Math expression using Javascript.It has all the basic functions supported with extensive support for new functions, variable etc.
5-
Plus it supports Sigma and Pi notations too. Also, any human readable math expression like `sincostan90` is also readable by this evaluator.
6-
7-
##[Demonstration](http://jsbin.com/qokime/edit?html,output)
8-
9-
#Topics
10-
11-
- [Features](#features)
12-
- [Supported symbols](#supported-symbols)
13-
- [Amazing support for Sigma and Pi](#amazing-support-for-sigma-and-pi)
14-
- [Parenthesis less expressions](#parenthesis-less-expression)
15-
- [Installation](#installation)
16-
- [Node JS](#node-js)
17-
- [Browser](#browser)
18-
- [Test](#test)
19-
- [Documentation](http://ankit31894.github.io/math-expression-evaluator/)
20-
21-
22-
# Installation
23-
## Node JS
24-
**Using npm**
25-
26-
npm install math-expression-evaluator
27-
28-
## Browser
29-
**Using bower**
30-
31-
bower install math-expression-evaluator
32-
# Features
33-
##Supported symbols
34-
35-
**+** Addition Operator eg. 2+3 results 5
36-
**-** Subtraction Operator eg. 2-3 results -1
37-
**/** Division operator eg 3/2 results 1.5
38-
**\*** Multiplication Operator eg. 2\*3 results 6
39-
**Mod** Modulus Operator eg. 3 Mod 2 results 1
40-
**(** Opening Parenthesis
41-
**)** Closing Parenthesis
42-
**Sigma** Summation eg. Sigma(1,100,n) results 5050
43-
**Pi** Product eg. Pi(1,10,n) results 3628800
44-
**n** Variable for Summation or Product
45-
**pi** Math constant pi returns 3.14
46-
**e** Math constant e returns 2.71
47-
**C** Combination operator eg. 4C2 returns 6
48-
**P** Permutation operator eg. 4P2 returns 12
49-
**!** factorial operator eg. 4! returns 24
50-
**log** logarithmic function with base 10 eg. log 1000 returns 3
51-
**ln** natural log function with base e eg. ln 2 returns .3010
52-
**pow** power function with two operator pow(2,3) returns 8
53-
**^** power operator eg. 2^3 returns 8
54-
**root** underroot function root 4 returns 2
55-
**Trigonometric function**
56-
**sin**
57-
**cos**
58-
**tan**
59-
**asin**
60-
**acos**
61-
**atan**
62-
**sinh**
63-
**cosh**
64-
**tanh**
65-
**asinh**
66-
**acosh**
67-
**atanh**
68-
69-
##Amazing support for Sigma and Pi
70-
This is a fantastic feature of this calculator that it is capable of evaluating expressions containing **Sigma and Pi**.
71-
Passing `Sigma(1,100,n)` will evaluate to 5050 as n is summationed from 1 to 100.
72-
and Pi(1,15,n) will evaluate to 1307674368000 as n is multiplied from 1 to 15 which is equal to 15!
73-
74-
##Parenthesis less expression
75-
If a expression is readable by human then it is readable by this evaluator. There is no need to wrap every function inside parenthesis.
76-
For eg. sin90 will work totally fine instead of sin(90)
77-
78-
# Test
1+
2+
3+
# Introduction
4+
An extremely efficient, flexible and amazing evaluator with a smart parser for Math expression using Javascript.It has all the basic functions supported with extensive support for new functions, variable etc.
5+
Plus it supports Sigma and Pi notations too. Also, any human readable math expression like `sincostan90` is also readable by this evaluator.
6+
7+
##[Demonstration](http://jsbin.com/qokime/edit?html,output)
8+
9+
#Topics
10+
11+
- [Features](#features)
12+
- [Supported symbols](#supported-symbols)
13+
- [Amazing support for Sigma and Pi](#amazing-support-for-sigma-and-pi)
14+
- [Parenthesis less expressions](#parenthesis-less-expression)
15+
- [Installation](#installation)
16+
- [Node JS](#node-js)
17+
- [Browser](#browser)
18+
- [Test](#test)
19+
- [Documentation](http://ankit31894.github.io/math-expression-evaluator/)
20+
21+
22+
# Installation
23+
## Node JS
24+
**Using npm**
25+
26+
npm install math-expression-evaluator
27+
28+
## Browser
29+
**Using bower**
30+
31+
bower install math-expression-evaluator
32+
# Features
33+
##Supported symbols
34+
35+
**+** Addition Operator eg. 2+3 results 5
36+
**-** Subtraction Operator eg. 2-3 results -1
37+
**/** Division operator eg 3/2 results 1.5
38+
**\*** Multiplication Operator eg. 2\*3 results 6
39+
**Mod** Modulus Operator eg. 3 Mod 2 results 1
40+
**(** Opening Parenthesis
41+
**)** Closing Parenthesis
42+
**Sigma** Summation eg. Sigma(1,100,n) results 5050
43+
**Pi** Product eg. Pi(1,10,n) results 3628800
44+
**n** Variable for Summation or Product
45+
**pi** Math constant pi returns 3.14
46+
**e** Math constant e returns 2.71
47+
**C** Combination operator eg. 4C2 returns 6
48+
**P** Permutation operator eg. 4P2 returns 12
49+
**!** factorial operator eg. 4! returns 24
50+
**log** logarithmic function with base 10 eg. log 1000 returns 3
51+
**ln** natural log function with base e eg. ln 2 returns .3010
52+
**pow** power function with two operator pow(2,3) returns 8
53+
**^** power operator eg. 2^3 returns 8
54+
**root** underroot function root 4 returns 2
55+
**Trigonometric function**
56+
**sin**
57+
**cos**
58+
**tan**
59+
**asin**
60+
**acos**
61+
**atan**
62+
**sinh**
63+
**cosh**
64+
**tanh**
65+
**asinh**
66+
**acosh**
67+
**atanh**
68+
69+
##Amazing support for Sigma and Pi
70+
This is a fantastic feature of this calculator that it is capable of evaluating expressions containing **Sigma and Pi**.
71+
Passing `Sigma(1,100,n)` will evaluate to 5050 as n is summationed from 1 to 100.
72+
and Pi(1,15,n) will evaluate to 1307674368000 as n is multiplied from 1 to 15 which is equal to 15!
73+
74+
##Parenthesis less expression
75+
If a expression is readable by human then it is readable by this evaluator. There is no need to wrap every function inside parenthesis.
76+
For eg. sin90 will work totally fine instead of sin(90)
77+
78+
# Test
7979
npm test

0 commit comments

Comments
 (0)