Comments (4)
Just have to deal with that problematic, and I agree with @LesterLyu there is no need for big.js
for such use case. You would need it only if you need number with more than 15 significant digits.
@or4 you should use toPrecision(15)
instead of toFixed(15)
so you can cut the number precision whatever the number of digit before or after the dot. See https://stackoverflow.com/a/36369703
Both JS and Excel use IEEE-754 double precision which can have 15 to 17 significant digits. While Excel retain 15 digits when representing number, JS can retain up to 17 digits with the risk of having inaccurate 16th & 17th digits. While it's better for computation, it's not desirable for representation where you should limit to 15 digits to have only accurate digits
Demo in JS, you can compare that toPrecision(15)
works as in Excel (when formatting with enough decimal)
n = 0.2**-2;
console.log(n);
console.log(Number(n.toFixed(15)));
console.log(Number(n.toPrecision(15)));
console.log();
n = 0.1+0.2;
console.log(n);
console.log(Number(n.toFixed(15)));
console.log(Number(n.toPrecision(15)));
console.log();
n = 1234567890123451234;
console.log(n);
console.log(Number(n.toFixed(15)));
console.log(Number(n.toPrecision(15)));
console.log();
24.999999999999996
24.999999999999996
25
0.30000000000000004
0.3
0.3
1234567890123451100
1234567890123451100
1234567890123450000
@LesterLyu should the documentation updated with that information that can help people to deal with that ? And the demo too ?
from fast-formula-parser.
24.999999999996
should be fine. See link
If you want to display the number, please use SSF to format the value into number format.
SSF usage
from fast-formula-parser.
Also keep in mind big.js
is super slow in calculation, which is not ideal.
See the benchmark.
from fast-formula-parser.
hi, gus, thanks a lot for answers
it is very useful, thanks again!
from fast-formula-parser.
Related Issues (20)
- Parsing error with quotes HOT 2
- Adding numbers to dates HOT 2
- Diagram errors HOT 1
- Parsing some inputs that are invalid in Excel HOT 2
- README.md lines 101-106 unnecessary HOT 2
- onVariable - access to cell position HOT 9
- Return formula result datatype HOT 2
- Return full argument in _callFunction
- Decimal without leading zero HOT 1
- Is there any plan/time table for Type definitions?
- Parse ASYNC used with 2 unimplemented functions cause UnhandledPromiseRejectionWarning
- Support for partial column and row references
- How to parse โexcel formula' using node js to get the actual value from the excel sheet.
- variables are treated differently than cells - why? and any workarounds?
- Is this project still supported/maintained? HOT 1
- Dependency parsing of index formulas in incorrect
- SEARCH and COUNTIF array criteria breaking
- Is this repository still maintained ?
- How to handle formula with dependent arguments containing formula? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fast-formula-parser.