wqz20263387

Perform high-precision monetary calculations in the browser using big.js to avoid JavaScript floating-point errors. Use when Big.js is needed for commission calculations or high-precision decimal arithmetic.

Installation

Review the source and dependencies with a prompt. A package is available to download.

Install with an AI assistant

Copy the prompt so your assistant can review the pinned revision and dependencies first.

View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "wqz20263387" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-20bc78a8486d03d26a588bf03f7be22f7c7839ac1e2fdb13de8ccad4c8b86ed3. Verify the upstream source and version against https://skillhub.cn/skills/user_f1b049da/wqz20263387 before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.

Source and setup

skillhub.cn

Setup guidance pending

See the original source for supported tools, dependencies, and permissions.

Installation test pending

Perform high-precision monetary calculations in the browser using big.js to avoid JavaScript floating-point errors. Use when Big.js is needed for commission calculations or high-precision decimal arithmetic.

0 Downloads

Introduction source: third_party · user_f1b049da · 1.0.0 Reference

SkillPi interpretation

Tasks
Translation pending; see source documentation.
Testing
Not tested

Browse files

Browse files at the source ↗

Original SKILL.md

Open original ↗
Frontmatter
name: wqz20263387
slug: wqz20263387
displayName: Big.js金额运算
version: 1.0.0
summary: 用 Big.js 做高精度十进制金额加减乘,避免提成/利润浮点误差。
license: MIT
description: 用 big.js 在浏览器内做高精度金额运算,规避 JS 浮点误差。当用户要 Big.js、提成金额运算、高精度小数时使用。

Big.js 金额运算(big.js)

灵感:能力工具箱 bigjs(pkg: big.js)。

小四原创:提成、利润、合计用十进制字符串入参,禁止直接 0.1+0.2。与 currency.js / decimal.js 可择一为主。

何时使用

  • 提成比例 × 业绩额
  • 多笔回款合计
  • 需要可预期的四舍五入到分

硬约束

  1. 使用 big.js;金额入参优先 string。
  2. 展示前 toFixed(2)(或业务位数);中间步骤可保留更多位。
  3. 除零、非法数字要捕获并中文提示。
  4. 实现要点注释标 小四原创。
  5. 与 currency.js 并存时:约定项目主库,勿混算同一链路。

推荐实现

import Big from 'big.js'

Big.DP = 4
Big.RM = Big.roundHalfUp

// 小四原创:提成试算
export function calcCommission(amount: string, ratePercent: string) {
  try {
    const a = new Big(amount)
    const r = new Big(ratePercent).div(100)
    const raw = a.times(r)
    return { ok: true as const, value: raw.toFixed(2), raw: raw.toString() }
  } catch {
    return { ok: false as const, error: '金额或比例无效' }
  }
}

// 小四原创:多笔合计
export function sumAmounts(list: string[]) {
  try {
    const total = list.reduce((acc, x) => acc.plus(x || '0'), new Big(0))
    return { ok: true as const, value: total.toFixed(2) }
  } catch {
    return { ok: false as const, error: '存在非法金额' }
  }
}

Agent 步骤

  1. 封装 calcCommission / sumAmounts。
  2. UI 输入当字符串传,不先 Number()。
  3. 自测:0.1+0.2 场景、提成两位小数、空串。

不要做

  • 用原生 number 累加再 toFixed「碰运气」。
  • 把加密货币高精度需求未经说明塞进两位金额默认。

附加

Current listing version

1.0.0

Verify the source revision ↗

Quality assessment

Out of 100 · Assessment report from SkillPi LAB.

Scenario Value80/100

Highlights

  • 解决 JS 浮点误差导致的金额计算不精确问题,适用于提成、利润、回款合计等金融场景
  • 具有明确实用价值,属于通用工具范畴
Trigger Precision85/100

Highlights

  • 触发词明确提及 'Big.js、提成金额运算、高精度小数',覆盖合理,边界清晰
Structure and Standards88/100

Highlights

  • 文档结构清晰,包含何时使用、硬约束、推荐实现、Agent 步骤、不要做等章节
  • 有代码示例,frontmatter 完整
Execution Reliability85/100

Highlights

  • 推荐实现中包含 try-catch 异常处理,对非法输入有中文提示
  • 工具来源明确(big.js),参数使用规范
Evidence Verifiability (mean of the first four)85/100

The arithmetic mean of the first four original scores, rounded to a whole number.

Static text checks

100 / 100 · skillpi-20261123-no-r3-v1

No current rules matched the text.

This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.

Permissions and checks before use

Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.

These common operations were not identified in the main document. This does not mean no permissions or risks exist.

These notices grant no permissions. Your host tool must still confirm file changes, secrets, external transfers or costs as needed.

Security rating and access scope

safe · Static evidence review; not a runtime safety guarantee.

Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.