calculator_skill
- TypeScript
346
GitHub Stars
1
Bundled Files
2 months ago
Catalog Refreshed
4 months ago
First Indexed
Readme & install
Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.
Installation
Preview and clipboard use veilstrat where the catalogue uses aiagentskills.
npx veilstrat add skill code-and-sorts/awesome-copilot-agents --skill calculator- SKILL.md1.8 KB
Overview
This skill performs arbitrary-precision arithmetic using a decimal math library to avoid floating-point errors. It handles addition, subtraction, multiplication, division, integer exponents, and parenthetical expressions with correct operator precedence. Use it when exact decimal results matter or when evaluating user-supplied arithmetic expressions.
How this skill works
The skill parses a textual arithmetic expression, respecting parentheses and operator precedence, then evaluates it using arbitrary-precision decimal arithmetic (big.js). Exponentiation is right-associative and requires integer exponents. Errors are raised for empty input, mismatched parentheses, division by zero, or non-integer exponents.
When to use it
- When a user asks to calculate, compute, or evaluate a math expression
- When precise decimal results are needed (avoid 0.1 + 0.2 floating-point noise)
- When expressions include parentheses and operator precedence
- When working with integer exponents and high-precision decimal arithmetic
- For simple numeric evaluation without variables or symbolic math
Best practices
- Provide a single well-formed expression string without variables
- Use parentheses to make precedence explicit and avoid ambiguity
- Keep exponents as integers to ensure correct evaluation
- Validate input length and characters before evaluation to prevent injection
- Handle and surface errors: empty input, mismatched parentheses, division by zero
Example use cases
- Evaluate money calculations where exact decimal cents matter (e.g., 19.95 * 3 / 7)
- Compute nested expressions with parentheses like (2 + 3) * 4 or 1 + 4.5 * (3 - 6) / 5
- Calculate large integer powers such as 2 ^ 10 or right-associative chains like 2 ^ 3 ^ 2
- Avoid JavaScript floating-point surprises such as 0.1 + 0.2
- Run quick arithmetic checks inside scripts or tools that require precise decimal output
FAQ
No. It only supports basic arithmetic, parentheses, and integer exponents.
What happens with non-integer exponents?
Non-integer exponents are not supported; the underlying decimal pow requires integer exponents and will error.