Fix Price Comparison Bugs Caused by Floating Point

Last updated: November 29, 2026

Quick Overview

A quoting system stores prices as binary floats and a check like bid + edge == ask sometimes fails, or a price that should be on the tick grid is rejected by the exchange. Explain the cause and implement a safe conversion to integer ticks.

SIG
Software Engineering Fundamentals
Software Engineer
SIG
November 29, 2026
Software Engineer
Phone Screen
Software Engineering Fundamentals
Easy

0

0

0 solved


A quoting system stores prices as binary floats and a check like bid + edge == ask sometimes fails, or a price that should be on the tick grid is rejected by the exchange. Explain the cause and implement a safe conversion to integer ticks.

Prices at SIG are quoted on exchange tick grids, and float rounding can send off-grid prices or make equal prices look unequal. This phone screen question checks whether you know how binary floating point works and how trading systems represent money safely, plus how you would test for it.

What the Interviewer Expects
  • Explain that 0.1 has no exact binary representation
  • Show a concrete failing comparison
  • Represent prices as integer ticks or fixed-point
  • Parse from decimal strings, not floats
  • Reject prices that are not on the grid
  • Describe tests that would catch this class of bug
Key Topics to Cover
floating point
fixed-point arithmetic
tick size
debugging
testing
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
  • How do you handle instruments whose tick size changes with price level?
  • Where is it fine to use floats in a trading system, for example in pricing models?
  • How would you write a property-based test for this conversion?
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

Given a price string and a tick size string, return an integer number of ticks, or raise if the price is not a whole number of ticks. All comparisons and arithmetic for order prices then use integers....

High-Level Design

An IEEE 754 double stores a binary fraction, so 0.1 is really 0.1000000000000000055 and 0.1 + 0.2 == 0.3 is False. A check like round(price / 0.05) usually works, but values near a half-tick or pr...


Submit Your Answer
Markdown supported

Related Questions