Claude Haiku 5.5 (effort default (no --effort flag) · thinking on) on Make invoice maths exact: half-up line rounding, per-rate VAT, largest-remainder allocation, banker's FX rounding
AClaude Haiku 5.5default · thinking on · Claude Code 2.1.299 (headless -p) · cloud · 2026-10-17 · by @bobsiopener
- Estimated cost
- $0.0070
- Wall time
- 30s
- Human step-ins
- 0
- Outcome
- Pass
Compare with other models on this task →
Summary
Exact prompt
# Task: make the invoice maths exact `money.py` uses binary floats and produces off-by-a-cent results. Fix it so these rules hold exactly (inputs and outputs are decimal strings; keep the function names and signatures): **All functions:** every returned amount is a string with exactly the target currency's decimals (e.g. "0.00", "-1.50", "1200" for JPY, "1.001" for BHD). Never output a negative zero such as "-0.00": a zero is always unsigned. `currency`/`to_currency` default to EUR where shown. **invoice(lines, currency)** - Line net = price x qty x (1 - discount_pct/100), rounded **half-up** (away from zero on .5) to the currency's decimals (EUR/USD 2, JPY 0, BHD 3). `qty` may be fractional, `discount_pct` is optional (default 0). Negative prices (credit lines) are allowed: half-up means 0.5 rounds away from zero for them too. - `net` = sum of rounded line nets. VAT is computed **per VAT rate** on that rate's summed rounded nets and rounded half-up. `vat` maps each rate string exactly as given (e.g. "20", "5.5") to its amount, in first-appearance order. `gross` = net + sum of VAT amounts. **allocate(amount, weights, currency)** - Split `amount` in proportion to non-negative integer `weights` (at least one positive) so that the parts sum **exactly** to amount: floor each exact share to the smallest unit (toward negative infinity for negative amounts — i.e. compute on the absolute value and re-apply the sign), then hand out remaining smallest units one each to the parts with the largest remainders; ties (equal remainders) go to the lower index. Example: `allocate("0.05", [3, 7])` -> `["0.02", "0.03"]` (exact shares 1.5 and 3.5 cents, equal remainders, the extra cent goes to index 0). Zero weight gets zero. Raise `ValueError` if all weights are 0. **convert(amount, rate, to_currency)** - amount x rate, rounded **half-even** (banker's) to the target decimals. Standard library only. No network.
Float classics (1.005, 2.675), half-up for negatives, VAT on grouped rounded nets, -0.00 suppression, 0/2/3-decimal currencies, deterministic largest-remainder tie-breaks and half-even conversion all have exact expected strings. Original benchmark task written for usecaserank.com (not based on a specific public post). Headless, offline run on a reproducible fixture. Each run's notes say how its cost was measured (estimates are marked).
Success criteria: 1. All 9 hidden unittest cases pass: half-up line rounding incl. float traps, discount + fractional qty, VAT grouping and order, credit lines and no '-0.00', JPY/BHD decimals, empty invoice, allocation (ties, zero weights, negatives, ValueError), allocation sums exactly, half-even conversion.
Setup notes: Use Case Scout batch 6 case f04-money-precision (offline fixture). Prepared with batch6/prepare.sh; hidden key/tests kept outside the agent's work dir. Prompt = TASK.md verbatim. Scored with the scout's scorer: `python score.py WORKDIR KEYDIR`. Tools: Read/Write/Edit/Glob/Grep/Bash, web disabled. Single run, no retries. Claude Code's own reported cost for claude-haiku-5.5: $0.006982. Score: 9/9. Cost is an ESTIMATE: measured tokens x pricing.json list price (Claude Pro subscription, nothing billed); input_tokens include cache reads and writes. Single run.
Estimated cost List-price estimate; not actually billed.
Metrics
- Estimated cost
- $0.0070
- Wall time
- 30s
- Human step-ins
- 0
- Turns
- 5
| Model | Input tok | Output tok | Cost |
|---|---|---|---|
| AClaude Haiku 5.5anthropic/claude-haiku-5.5effort default (no --effort flag) · thinking on | 115,087 | 6,351 | $0.0070 |
Reproduce this run
- Use the use case prompt on the use case page.
- Same setup: Claude Haiku 5.5 (anthropic/claude-haiku-5.5, effort default (no --effort flag) · thinking on) via
Claude Code 2.1.299 (headless -p), cloud. - It counts as a success only if it meets every success criterion: 1. All 9 hidden unittest cases pass: half-up line rounding incl. float traps, discount + fractional qty, VAT grouping and order, credit lines and no '-0.00', JPY/BHD decimals, empty invoice, allocation (ties, zero weights, negatives, ValueError), allocation sums exactly, half-even conversion.
- Log model, tokens, wall time, human step-ins and the evidence log, then submit it as a reproduction. A different model? Submit a head-to-head rerun.
How runs are scored: Methodology.
Was this useful?
Automated checks
Trust 80% comes from these checks (how Trust % works).
- Run date is not in the future : passed
- Model is in the dated pricing table : passed
- Cost recomputed from tokens matches : passed
- Cached tokens are consistent : passed
- Output throughput is plausible : passed
- Autonomy matches step-ins : passed
- Step-ins do not exceed turns : passed
- Retries agree with first-try result : passed
- Evidence log SHA-256 matches : passed
- Evidence log is substantial : passed
Evidence log
[
{
"duration_api_ms": 28895,
"stop_reason": "end_turn",
"session_id": "[REDACTED]",
"total_cost_usd": 0.00698214,
"usage": {
"input_tokens": 10,
"cache_creation_input_tokens": 13973,
"cache_read_input_tokens": 101104,
"output_tokens": 6351,
"output_tokens_details": {
"thinking_tokens": 3172
},
"server_tool_use": {
"web_search_requests": 0,
"web_fetch_requests": 0
},
"service_tier": "standard",
"cache_creation": {
"ephemeral_1h_input_tokens": 13973,
"ephemeral_5m_input_tokens": 0
},
"inference_geo": "global",
"iterations": [
{
"input_tokens": 2,
"output_tokens": 1166,
"cache_read_input_tokens": 25361,
"cache_creation_input_tokens": 1151,
"cache_creation": {
"ephemeral_5m_input_tokens": 0,
"ephemeral_1h_input_tokens": 1151
},
"type": "message"
}
],
"speed": "standard",
"fallback_credit": null
},
"modelUsage": {
"claude-haiku-5-5": {
"inputTokens": 10,
"outputTokens": 6351,
"cacheReadInputTokens": 101104,
"cacheCreationInputTokens": 13973,
"webSearchRequests": 0,
"costUSD": 0.00698214,
"contextWindow": 1000000,
"maxOutputTokens": 128000,
"thinkingTokens": 3172,
"canonicalModel": "claude-haiku-5-5",
"provider": "firstParty",
"costBasis": "list"
}
},
"permission_denials": [],
"terminal_reason": "completed",
"fast_mode_state": "off",
"fast_mode_disabled_reason": "sdk_opt_in_required",
"subagent_stats": {
"spawned": 0,
"requested": {
"background": 0,
"foreground": 0,
"unset": 0
},
"started_in_background": 0,
"max_depth": 0,
"spawned_by_subagents": 0,
"completed": 0,
"failed": 0,
"killed": {
"parent": 0,
"user": 0,
"system": 0
},
"refused": {
"depth_limit": 0,
"concurrency_limit": 0,
"budget": 0
},
"by_type": {}
},
"safety_stops": 0,
"is_error": false,
"num_turns": 5,
"subtype": "success",
"api_error_status": null,
"result": "I rewrote `money.py` so every rule in the spec is computed exactly. I ran the spec examples and some edge cases by hand; I did not add a test file, and the directory has no existing tests.\n\nWhat changed:\n- **Exact arithmetic:** inputs are parsed with `Fraction`, so binary float error is gone. Rounding happens only at the points the spec names, in integer minor units.\n- **Rounding:** `invoice` and `allocate` use half-up, computed on the absolute value so it works for negatives. `convert` uses Python's `round()` on a `Fraction`, which is half-even.\n- **Formatting:** one helper formats minor units to the currency's decimals and never emits a sign for zero, so \"-0.00\" cannot appear.\n- **Signatures:** unchanged. The `currency=\"EUR\"` defaults on `invoice` and `allocate` are kept, and `convert` still has no default.\n\nChecks run:\n- `allocate(\"0.05\", [3, 7])` gives `['0.02', '0.03']`, and the negative case mirrors it.\n- `allocate(\"10.00\", [1, 1, 1])` gives `['3.34', '3.33', '3.33']`.\n- `invoice` with price \"2.675\", qty 3, 10% discount, VAT 20 gives net \"7.22\", VAT \"1.44\", gross \"8.66\".\n- Credit lines of \u00b10.005 net to \"0.00\" with no negative zero.\n- The BHD example `1.0005` rounds to \"1.001\".\n- `convert(\"0.125\")` gives \"0.12\" and `convert(\"0.135\")` gives \"0.14\".\n\nChoices I made where the spec was silent:\n- `allocate` raises `ValueError` if `amount` has more decimals than the currency allows, since the parts could not sum exactly to it.\n- `allocate` raises `ValueError` for negative or non-integer weights, not just for all-zero weights.\n- VAT rate keys are used as given, so \"20\" and \"20.0\" would be two separate entries.",
"ttft_ms": 1368,
"type": "result",
"duration_ms": 29311,
"uuid": "[REDACTED]",
"ttft_stream_ms": 1174,
"time_to_request_ms": 279,
"first_content_frame_ms": 1175,
"queued_turn_count": 0,
"result_index": 0
}
]