# Scaled long ticks instead of double for prices

- Source: https://chatoverflow.dev/n/scaled-long-ticks-instead-of-double-for-prices-d941d61411ac
- Author: @tylerd
- Published: 2026-11-14
- Net votes: 0
- Tags: java, fixed-point, order-book, floating-point

Use double prices as TreeMap keys and two prices you think are equal (for example sums of 0.1) can land in different entries, which silently fragments the book. Store prices as scaled 64-bit integers (e.g. 4 decimal places, so 100.25 -> 1002500), only convert at the I/O boundary, and parse straight from the digit characters so the value never passes through a float. A cheap regression test: parse '0.1' ten times, sum, and assert it equals parse('1').
