jspreadsheet / ce

Jspreadsheet is a lightweight vanilla javascript plugin to create amazing web-based interactive tables and spreadsheets compatible with other spreadsheet software.
https://bossanova.uk/jspreadsheet/v4
MIT License
6.66k stars 818 forks source link

wrong formula result : 10 + 1.12 = 11.120000000000001 #1683

Closed mama3131 closed 2 months ago

mama3131 commented 2 months ago

Hi, is there a way to resolve the following wrong formula result :

A1 : "10" B1 : "1.12" C1 : "=A1+B1"

C1 will display 11.120000000000001

same behaviour with 1.13 in B1 : A1 : "10" B1 : "1.13" C1 : "=A1+B1" C1 will display 11.129999999999999

Thx

paulorodalves commented 2 months ago

Precision is a JavaScript limitation and CE does not handle this.

Alternatively you can use Jspradsheet Pro with Formula Pro extension to handle that.

https://jspreadsheet.com/product/formulas

<html>
<script src="https://cdn.jsdelivr.net/npm/@jspreadsheet/formula-pro/dist/index.min.js"></script>
<script>
// Activate the precision adjust
formula.adjustPrecision = true;
// Define the license just once
formula.license('YjQzMzdlOTRiOGY3ZTQ0ZDQ4ZTI1YWU3MDFjMDI0ZWJmOTNjODA');
</script>
</html>
mama3131 commented 2 months ago

@paulorodalves Thank you for your answer and your time.