# jsbi-calculator **Repository Path**: leslie_wong/jsbi-calculator ## Basic Information - **Project Name**: jsbi-calculator - **Description**: JSBI-Calculator是一个IE11兼容的计算器JS库组件,用于实现高精度(至多18位小数)大数值四则运算,基于由谷歌Chrome实验室出品的JSBI封装的BigDecimial。 - **Primary Language**: JavaScript - **License**: Apache-2.0 - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 2 - **Forks**: 0 - **Created**: 2023-04-27 - **Last Updated**: 2024-06-22 ## Categories & Tags **Categories**: Uncategorized **Tags**: 数学, 大数, BigDecimal, 四则运算 ## README # JSBI-Calculator [](https://github.com/Leslie-Wong-H/jsbi-calculator/blob/master/LICENSE) [](https://app.codecov.io/gh/Leslie-Wong-H/jsbi-calculator/branch/main) [](https://github.com/Leslie-Wong-H/jsbi-calculator/actions) [](https://github.com/Leslie-Wong-H/jsbi-calculator/releases/latest) [](https://www.npmjs.com/package/jsbi-calculator) JSBI-Calculator是一个IE11兼容的计算器JS库组件,用于实现高精度(至多18位小数)大数值四则运算,基于由谷歌Chrome实验室出品的JSBI封装的BigDecimal。 该项目反哺[GoogleChromeLabs/jsbi](https://github.com/GoogleChromeLabs/jsbi/issues/79)作出了不凡贡献。 ## 安装 ``` > npm install jsbi-calculator ``` ## 示例  ## 用法 > ES6模块: ```js import JBC from "jsbi-calculator"; const { calculator } = JBC; const expressionOne = "((10 * (24 / ((9 + 3) * (-2)))) + 17) + 5"; const resultOne = calculator(expressionOne); console.log(resultOne); // -> '12' const max = String(Number.MAX_SAFE_INTEGER); console.log(max); // -> '9007199254740991' const expressionTwo = `${max} + 2`; const resultTwo = calculator(expressionTwo); console.log(resultTwo); // -> '9007199254740993' ``` > Node CommonJS模块: ```js const JBC = require("jsbi-calculator"); const { calculator } = JBC; const expressionOne = "((10 * (24 / ((9 + 3) * (-2)))) + 17) + 5"; const resultOne = calculator(expressionOne); console.log(resultOne); // -> '12' const max = String(Number.MAX_SAFE_INTEGER); console.log(max); // -> '9007199254740991' const expressionTwo = `${max} + 2`; const resultTwo = calculator(expressionTwo); console.log(resultTwo); // -> '9007199254740993' ``` > 浏览器: ```html