@fitchmultz/pi-calculator

中文文档
4.1.5发布于 2026/11/01MITES Module构建来源已验证

Deterministic high-precision calculator tool for Pi

原始使用文档
文档目录5 节
  1. Install and try it
  2. Expressions
  3. Results and limits
  4. Verification
  5. License

pi-calculator

pi-calculator adds a calculator tool to Pi, with 40 significant digits of decimal precision. Use it to check totals or evaluate scientific expressions.

Pi sends an expression to the calculator, which returns a decimal result or rejects an invalid expression.

Install and try it

Use Node.js and a supported Pi release. See the compatibility requirements.

pi install npm:@fitchmultz/pi-calculator
pi

Enter this prompt in the new Pi session:

Use the calculator to evaluate [0.1 + 0.2, 2^64].

The calculator tool returns ["0.3","18446744073709551616"].

See installation options for Git installs or a change from Git to npm.

Pi extensions run with full system access. Review the source before you install the package.

Expressions

Try these expressions:

percent(15, 200)                 → 30
roundTo(-1.25, 1)                → -1.3
mean([2,4,6,8])                  → 5
sin(radians(90))                 → 1
sum([1e40,1,-1e40])              → 1
(12.5 * 1.0825) ^ 3              → 2477.500518798828125

Arithmetic supports +, -, *, /, %, ^ and **, with PI and E as constants. Put independent calculations in one flat array, as in the first example.

Trig uses radians. Use radians() to convert degrees to radians. Use degrees() to convert radians to degrees.

roundTo(value, places) rounds half values away from zero. Use negative places to round to tens, hundreds or larger units.

See the expression reference for all functions and array indexing.

Results and limits

Results are decimal strings, or a flat array of decimal strings. Input numbers and arithmetic use half-up rounding. Large finite results use scientific notation.

The calculator tool rejects invalid expressions, nonfinite results and nested result arrays. If one result in an array is invalid, the calculator tool rejects the whole expression.

Keep expressions within 4,096 characters. See limits for nesting, output size and work budgets.

See result format to use the calculator tool from another extension.

Read the migration notes before upgrading.

Verification

See the development guide for local checks and Pi compatibility tests. See the changelog for release history.

License

MIT © Mitchell Fultz.

版本与发布记录

@fitchmultz/pi-calculator 共发布 6 个版本,首次发布于 2026/10/06;过去 12 个月发布了 6 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
4.1.5latest2026/11/012 天前
4.1.42026/11/012 天前
4.1.32026/11/012 天前
4.1.22026/11/012 天前
4.1.12026/10/0628 天前
0.0.0-stage2026/10/0628 天前

关于 @fitchmultz/pi-calculator 的常见问题

@fitchmultz/pi-calculator 是什么?

确定性高精度的圆周率计算器工具

如何安装 @fitchmultz/pi-calculator?

在项目目录运行 npm install @fitchmultz/pi-calculator,或使用 pnpm add / yarn add / bun add。

@fitchmultz/pi-calculator 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/fitchmultz__pi-calculator 是否存在。

@fitchmultz/pi-calculator 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@fitchmultz/pi-calculator 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=24.0.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@fitchmultz/pi-calculator 可以商用吗?

@fitchmultz/pi-calculator 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@fitchmultz/pi-calculator 还在维护吗?

最新版本 4.1.5 发布于 2026/11/01(2 天前);至今共发布 6 个版本,其中过去 12 个月发布了 6 个;首次发布于 2026/10/06。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。