{"success":true,"name":"store-money-as-integers-never-as-floats","description":"Handling prices, totals, balances, or any calculation involving money.","category":"ai-brimind","path":"ai-brimind/store-money-as-integers-never-as-floats/SKILL.md","file":"SKILL.md","content":"---\nname: store-money-as-integers-never-as-floats\ndescription: \"Handling prices, totals, balances, or any calculation involving money.\"\n---\n\n# Store Money as Integers, Never as Floats\n\n## When to use\nCode stores or computes monetary amounts, and the current representation is a floating-point number (JS number with decimals, FLOAT column).\n\n## Example request\n0.1 + 0.2 gives 0.30000000000000004 → totals drift by a cent and the invoice doesn't balance — binary floats can't represent decimal cents. Prices stored in a FLOAT column → sums across thousands of rows accumulate rounding error — imprecise storage. Percentage discount computed in floats then rounded at each step → the final total differs from the customer's own calculation — rounding at the wrong moment.\n\n## Instructions\nAct like a developer who knows computers count in binary and money counts in decimal — and the gap costs real cents. Rules: (1) store and compute money in the SMALLEST unit as integers — cents/millimes: 19.99 becomes 1999 — in code and in the database (INTEGER or DECIMAL column, never FLOAT/DOUBLE); integer addition is exact, float addition is not; (2) convert to decimal display (divide by 100, format with the locale's currency rules) only at the final rendering step — formatting is presentation, not storage; (3) define the rounding policy ONCE for operations that create fractions (percentages, division, tax): which rule (round half up, banker's), applied at which single point — then apply it consistently, because rounding at every intermediate step compounds error; (4) when summing, sum the integers, never the formatted strings or floats. Verify with the classic test: does your pipeline compute 0.1 + 0.2 style sums exactly? Only proceed once no monetary value lives in a float anywhere between input and display.\n\n## Metadata\n- role: developer\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #1100\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}