Track Down a Floating-Point Drift Bug in Ad Revenue Totals

Last updated: November 29, 2026

Quick Overview

A daily revenue report for advertisers is off by a few cents compared with the invoicing system, and the gap grows with volume. Find the root cause, fix the summation and rounding, and add tests that pin the behavior down.

Google
Software Engineering Fundamentals
Software Engineer
Google
November 29, 2026
Software Engineer
Technical Screen
Software Engineering Fundamentals
Medium

0

0

0 solved


A daily revenue report for advertisers is off by a few cents compared with the invoicing system, and the gap grows with volume. Find the root cause, fix the summation and rounding, and add tests that pin the behavior down.

Google Ads reconciles reports and invoices across huge volumes, where float drift turns into visible discrepancies and support tickets. The interviewer checks debugging from symptoms (small, growing, systematic error), knowledge of binary floating point, and a fix that uses integer minor units with an explicit rounding mode.

What the Interviewer Expects
  • Connects a small error that grows with row count to floating-point accumulation
  • Explains why values like 0.1 are not exact in binary
  • Moves money to integer micros or cents, parsed from strings
  • Chooses and documents a rounding mode and where rounding happens
  • Adds regression tests with known-bad float cases
Key Topics to Cover
floating point
money handling
rounding modes
debugging
regression tests
How to Approach This
  1. Apply SOLID principles. Single Responsibility makes code testable, Open/Closed makes it extensible.
  2. Choose data structures based on access patterns, not familiarity.
  3. Prefer immutable data and message passing over shared mutable state for concurrency.
  4. Design APIs with RESTful conventions, versioning, meaningful errors, and pagination from day one.
Possible Follow-up Questions
  • Google Ads uses micros: why might a millionth of a unit be the right base?
  • Where should rounding happen when tax applies to each line versus the total?
  • How would you reconcile two systems that already disagree historically?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice System Design Problems
Sample Answer
Requirements
  • Totals must match the invoice system exactly.
  • Inputs arrive as decimal strings from the billing feed.
  • Tax is applied per line with half-up rounding to the cent (state the policy and confirm it)....
High-Level Design

Symptom analysis: the error is tiny, one-directional on average, and scales with volume, which points to accumulated representation error, not a logic bug in any one row. In binary, 0.1 is a repeating...


Submit Your Answer
Markdown supported