Skip to content

Claude Sonnet 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 Sonnet 5.5default · thinking on · Claude Code 2.1.299 (headless -p) · cloud · 2026-10-17 · by @bobsiopener

Trust 80%Fully autonomoussuccess · first try
Estimated cost
$0.07
Wall time
24s
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-sonnet-5.5: $0.070722. 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.07
Wall time
24s
Human step-ins
0
Turns
5
Model usage
ModelInput tokOutput tokCost
AClaude Sonnet 5.5anthropic/claude-sonnet-5.5effort default (no --effort flag) · thinking on80,8242,683$0.07

Reproduce this run

  1. Use the use case prompt on the use case page.
  2. Same setup: Claude Sonnet 5.5 (anthropic/claude-sonnet-5.5, effort default (no --effort flag) · thinking on) via Claude Code 2.1.299 (headless -p), cloud.
  3. 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.
  4. 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?

⇄ Rerun on another model

Automated checks

Trust 80% comes from these checks (how Trust % works).

Evidence log
[
 {
  "duration_api_ms": 22516,
  "stop_reason": "end_turn",
  "session_id": "[REDACTED]",
  "total_cost_usd": 0.0707218,
  "usage": {
   "input_tokens": 8,
   "cache_creation_input_tokens": 9178,
   "cache_read_input_tokens": 71638,
   "output_tokens": 2683,
   "output_tokens_details": {
    "thinking_tokens": 316
   },
   "server_tool_use": {
    "web_search_requests": 0,
    "web_fetch_requests": 0
   },
   "service_tier": "standard",
   "cache_creation": {
    "ephemeral_1h_input_tokens": 9178,
    "ephemeral_5m_input_tokens": 0
   },
   "inference_geo": "global",
   "iterations": [
    {
     "input_tokens": 2,
     "output_tokens": 568,
     "cache_read_input_tokens": 21203,
     "cache_creation_input_tokens": 514,
     "cache_creation": {
      "ephemeral_5m_input_tokens": 0,
      "ephemeral_1h_input_tokens": 514
     },
     "type": "message"
    }
   ],
   "speed": "standard",
   "fallback_credit": null
  },
  "modelUsage": {
   "claude-sonnet-5-5": {
    "inputTokens": 8,
    "outputTokens": 2683,
    "cacheReadInputTokens": 71638,
    "cacheCreationInputTokens": 9178,
    "webSearchRequests": 0,
    "costUSD": 0.0707218,
    "contextWindow": 1000000,
    "maxOutputTokens": 128000,
    "thinkingTokens": 316,
    "canonicalModel": "claude-sonnet-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` to use exact rational arithmetic (`fractions.Fraction`) in place of floats. Function names and signatures are unchanged, and it uses only the standard library.\n\nI ran a few spot checks, not a full test suite, and they matched the rules:\n- **Allocate:** `allocate(\"0.05\", [3, 7])` gives `[\"0.02\", \"0.03\"]`. The negative case gives `[\"-0.02\", \"-0.03\"]`, and JPY `100` split three ways gives `[\"34\", \"33\", \"33\"]`.\n- **Zero sign:** a zero never carries a sign. A VAT amount of -0.00165 comes out as `\"0.00\"`, and `convert(\"-0.001\", \"1\", \"EUR\")` gives `\"0.00\"`.\n- **Rounding:** an invoice with a 2.675 \u00d7 3 line at 10% discount and a negative credit line rounds half-up away from zero (7.2225 \u2192 7.22, -0.025 \u2192 -0.03). `convert` rounds half-even, so 0.005 \u2192 `0.00` and 0.015 \u2192 `0.02`.\n- **Invoice:** the same two-line invoice gave net `7.19`, VAT `{\"20\": \"1.44\", \"5.5\": \"0.00\"}` and gross `8.63`.\n\nIf `allocate` gets an amount with more decimals than the currency allows, it first rounds that amount half-up to the smallest unit. The spec doesn't cover that case, so that was my choice.",
  "ttft_ms": 1948,
  "type": "result",
  "duration_ms": 22966,
  "uuid": "[REDACTED]",
  "ttft_stream_ms": 1310,
  "time_to_request_ms": 297,
  "first_content_frame_ms": 1310,
  "queued_turn_count": 0,
  "result_index": 0
 }
]

Get new runs and ranking changes weekly