百分比计算器

快速计算金额的百分比、折扣、税费和小费。

// about

工具介绍

输入金额和百分比,即可计算百分比数值以及加上它之后的金额。

如何使用

  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 for everyday percentage tasks: share, percent change, increases/decreases and reverse calculations.

## Core features

- What is B% of A
- A is what percent of B
- Percent change from A to B
- Increase or decrease A by B%
- Original price from a discounted price

## Inputs

- Two numbers per calculation type

## Outputs

- Result
- Formula and working shown step by step

## Edge cases and handling rules

- Explain division by zero when the base is 0
- Support negative and decimal numbers
- Rounding option to hide floating-point noise
- Note on percent versus percentage points

## 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)

- 15% of 80000 = 12000
- Change from 200 to 250 = 25%
- If 72000 is 20% off, the original is 90000

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-percent-calculator/SKILL.md,以后开发或修改此工具时可重复使用。

---
name: build-percent-calculator
description: Use when building or changing a 百分比计算器 tool. Build a calculator for everyday percentage tasks: share, percent change, increases/decreases and reverse calculations.
---

# Build: 百分比计算器

## Goal

Build a calculator for everyday percentage tasks: share, percent change, increases/decreases and reverse calculations.

## 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

- What is B% of A
- A is what percent of B
- Percent change from A to B
- Increase or decrease A by B%
- Original price from a discounted price

## Inputs

- Two numbers per calculation type

## Outputs

- Result
- Formula and working shown step by step

## Rules

- Explain division by zero when the base is 0
- Support negative and decimal numbers
- Rounding option to hide floating-point noise
- Note on percent versus percentage points
- 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

- [ ] 15% of 80000 = 12000
- [ ] Change from 200 to 250 = 25%
- [ ] If 72000 is 20% off, the original is 90000

交给 AI 时的小技巧

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