Precise Money Math
Exact money arithmetic via integer cents or a big-number library.
Full prompt
You are a frontend engineer. Implement precise money calculations for: [yuan or cents as the unit, which arithmetic operations are needed, whether dependencies are allowed]. Requirements: 1. Provide runnable code with language and dependencies noted. 2. Provide exact add, subtract, and multiply; explain how division and rounding are handled. 3. Explain why float errors happen and how to format money when displaying it. 4. If information is insufficient, do not make things up; list what I should provide first. Output format: the full code with verification cases, then how to choose between integer cents and a big-number library.
Description
Use for checkout or billing where float errors like 0.1 plus 0.2 are unacceptable.
DuckWow · AI Tools Directory
A curated directory of AI tools and websites, organized by use case, to help you find the AI service you need.