Money arithmetic audit: floating-point, rounding and allocation errors in billing code

par fidji DeepSeek Anglais ~702 tokens
Extrait public Verrouillé
Inventory of every money operation, the numeric type used, then worked counter-examples to the cent: 0.1 + 0.2, a 100.00 split three ways, tax rounded per line versus per invoice. Fix with integer minor units or decimals and a largest-remainder allocation…

À propos de ce prompt

Audits code that handles prices, taxes, discounts, currency conversion and payment splits for the cent-level errors that create accounting gaps: binary floating point, rounding per line versus per total, lost cents when splitting, double rounding. DeepSeek computes every case digit by digit and shows the discrepancy, so finance and developers can verify each finding by hand.

Exemple de résultat

Fourni par l'auteur
STEP 3 — COUNTER-EXAMPLES 1. Float sum (line 8): 0.1 + 0.2 = 0.30000000000000004 → `total === 0.3` is false; the "paid in full" check fails. 2. Rounding helper (line 14): Math.round(1.005 * 100) / 100. 1.005 * 100 = 100.49999999999999 → rounds to 100 → 1.00 instead of 1.01. Error: 0.01. 3. Split (line 31): 100.00 / 3 = 33.333… → rounded 33.33 × 3 = 99.99. Missing: 0.01 per split. Largest remainder: 10,000 cents / 3 = 3,333 rem 1 → parts 3,334 + 3,333 + 3,333 = 10,000 ✓ → 33.34, 33.33, 33.33. 4. Tax per line vs per invoice (20%, three lines at 0.99): Per line: 0.99 × 0.20 = 0.198 → 0.20; × 3 = 0.60 Per invoice: 2.97 × 0.20 = 0.594 → 0.59 Difference 0.01. Your rule says "per invoice": line 22 must change. STEP 4 — FIX Store amounts as integer cents; one helper roundHalfUp(cents, scale)…

Fiche technique

Modèle
DeepSeek
Langue du prompt
Anglais
Pour qui
Developers of invoicing, checkout, payroll or marketplace payout systems
Longueur
~702 tokens (estimation)
Format livré
Texte du prompt, affiché en ligne après achat

Avis

Réservés aux acheteurs

Aucun avis pour l'instant. Seuls les acheteurs de ce prompt peuvent en laisser un.

Signaler ce prompt