A risk system stores prices as double. A trader reports that 100 lots at 12.10 shows a notional of 1209.9999999999998, and that a limit priced at 1.23 plus 0.07 is rejected as off tick. Explain both, then state how you would store prices, quantities and P&L.

A risk system stores prices as double. A trader reports that 100 lots at 12.10 shows a notional of 1209.9999999999998, and that a limit priced at 1.23 plus 0.07 is rejected as off tick. Explain both, then state how you would store prices, quantities and P&L.

Approach: Ask which of these decimal values has an exact binary representation, then think about what an equality or a remainder test does once the stored value is the nearest double instead.

Neither 12.10 nor 0.07 has an exact representation in binary floating point, so the stored values are the nearest doubles and both the multiplication and the tick test operate on numbers slightly off the intended ones; store prices as an integer number of ticks, quantities as integers and P&L as a scaled integer or a decimal type, converting to double only for display and for models. A binary fraction can represent only sums of powers of two, so most decimal fractions are inexact. The notional is one rounding of the product showing through. The off tick rejection is a remainder test against a tick size that is itself inexact, so a residue of 1e-16 fails an exact comparison, and adding a tolerance patches the symptom while leaving the boundary ambiguous. Integer ticks make both operations exact and equality meaningful, at the cost of carrying the scale alongside every price.

Follow-up: How would you handle a venue that varies the tick size by price band without rewriting the stored prices?

Key concepts: binary floating point, exact representation, integer ticks, tick size.