分步公式计算器

按照运算顺序解决带括号的算术表达式并查看步骤。

// about

工具介绍

输入普通算术表达式,例如 (379*11900)+(75*20000)。计算器先算乘除再算加减,并显示每一步化简过程。

如何使用

  1. 输入数字以及 +、-、*、/ 和括号。
  2. 点击“计算表达式”。
  3. 查看每一步化简和最终结果。

人们为何使用此工具

  • 比基础计算器更清晰地处理长公式和嵌套括号。
  • 显示中间表达式,便于核对计算。
  • 支持四则运算,且不会执行任意代码。
指南 · 计算 · 约 3 分钟

百分比计算详解:增减率、百分点、叠加折扣与增值税

销售额增长了多少?促销价是多少?利率是上涨了 1% 还是 1 个百分点?百分比看似简单,但选错基数,答案就会改变。

百分比就是以一百为分母的比率。所有百分比计算都取决于能否选对基数(分母),日常中的大多数情况都属于以下四种之一。

① A 的 B% 是多少?        A × B ÷ 100          (80,000 的 15% = 12,000)
② A 是 B 的百分之几?     A ÷ B × 100          (12 ÷ 48 × 100 = 25%)
③ 从 A 到 B 的变化率      (B − A) ÷ A × 100    (200 → 250 = +25%)
④ A 增加/减少 B% 后       A × (1 ± B ÷ 100)    (50,000 + 20% = 60,000)
四个基本的百分比公式、百分比与百分点的区别、为什么打八折再打九折不是七折,以及如何从含税价中拆出税额。
阅读指南 →
用 AI 自己做

用 AI 亲手打造这个工具

想要自己的版本?把下面的任务提示词粘贴到 AI 聊天中,或将技能文件保存到 AI 编程助手。其中包含我们开发此工具时整理的功能、边界情况和测试用例。

提示词和技能以英文提供,AI 工具在任何语言环境下都能很好地理解。

AI 任务提示词

直接粘贴到 Claude、ChatGPT、Gemini 等 AI 聊天中即可。

You are an experienced full-stack web developer. Build a web tool called "分步公式计算器" that meets the requirements below.

## Goal

Build a calculator that evaluates expressions with arithmetic and parentheses and shows each intermediate step.

## Core features

- +, −, ×, ÷, parentheses and decimals
- Step-by-step working that follows operator precedence
- Accept thousands separators
- Copy result
- Recent history

## Inputs

- An expression string

## Outputs

- Final result
- List of intermediate results

## Edge cases and handling rules

- Implement a parser; never use eval
- Report mismatched parentheses with their position
- Handle division by zero
- Keep precision for large numbers and decimals (decimal arithmetic)

## Implementation requirements

- Build it as a single page (HTML, CSS, JavaScript) that runs entirely in the browser, and never send the user's input to a server.
- Make the UI responsive and easy to use on mobile; label every input and keep everything keyboard accessible.
- Add a Copy button for results and show clear, friendly error messages for invalid input.
- Keep the core logic in functions separate from the UI so it can be unit-tested.

## Definition of done (test cases)

- (379*11900)+(75*20000) = 6010100 with steps 4510100 and 1500000
- 2+3*4 = 14
- 1/0 shows an error

First outline your implementation plan in at most five lines, then write the complete code, and finally explain how to check the test cases above.

技能 (SKILL.md)

在 Claude Code 等 AI 编程助手中保存为 .claude/skills/build-expression-calculator/SKILL.md,以后开发或修改此工具时可重复使用。

---
name: build-expression-calculator
description: Use when building or changing a 分步公式计算器 tool. Build a calculator that evaluates expressions with arithmetic and parentheses and shows each intermediate step.
---

# Build: 分步公式计算器

## Goal

Build a calculator that evaluates expressions with arithmetic and parentheses and shows each intermediate step.

## Workflow

1. Review the required features, inputs and outputs below and ask about anything missing first.
2. Implement the core logic as pure functions separate from the UI.
3. Check the logic against the test cases in the verification list.
4. Build a responsive UI with an input form, a result area and a Copy button.
5. Reproduce each edge case listed under Rules and refine the error messages.

## Core features

- +, −, ×, ÷, parentheses and decimals
- Step-by-step working that follows operator precedence
- Accept thousands separators
- Copy result
- Recent history

## Inputs

- An expression string

## Outputs

- Final result
- List of intermediate results

## Rules

- Implement a parser; never use eval
- Report mismatched parentheses with their position
- Handle division by zero
- Keep precision for large numbers and decimals (decimal arithmetic)
- Build it as a single page (HTML, CSS, JavaScript) that runs entirely in the browser, and never send the user's input to a server.

## Verification

- [ ] (379*11900)+(75*20000) = 6010100 with steps 4510100 and 1500000
- [ ] 2+3*4 = 14
- [ ] 1/0 shows an error

交给 AI 时的小技巧

  • 在第一行写明技术栈(如 React、Vue 或纯 HTML),生成的代码会更贴合你的项目。
  • 在接受代码前,请让 AI 运行列出的测试用例并展示结果。
  • 不要把真实密码、客户数据或 API 密钥粘贴到提示词中,请用示例值代替。