Blog · Data · · 3 min read
Keeping every digit a scientist wrote
Almost every charting library and data pipeline treats floating-point numbers as disposable display strings: run toFixed(1) or round the JSON response to three significant digits and move on. On biological data that spans fourteen orders of magnitude, blanket rounding destroys real information while inventing fake precision at the same time.
In our own precision audit, rounding the wire format to three significant digits shifted box-whisker positions by several device pixels and turned a fossil interval of 201.4–227.3 Ma into 201–227. Rounding categorical weights independently turned a 0.25 minority tail beside 999,999.75 into 1,000,000, which made the readout falsely claim "all". Double rounding corrupts plain text too: a value just under 1.05 rounds to 1.05 on the wire and then to 1.1 in a two-digit label, whereas formatting the original number gives 1.0.
Spreadsheets and binary floats invent digits
The problem starts long before the browser sees a number. Published trait tables carry three common kinds of fake digits:
- AVONET's Excel sheet stores the common starling's mass as
77.09999999999999, which is IEEE-754's binary approximation of77.1. Parquet 32-bit floats in FishBase and SeaLifeBase similarly widen to 64-bit doubles with binary tails that the original author never typed. - EOL TraitBank converts a European hedgehog's 42-day weaning age into
0.114992years using365.2425-day years. Converting that back yields42.0009days instead of42. - BIRDBASE stores a computed mean for the European robin to sixteen digits while formatting the column to
0.00. AVONET stores the common raven's mass formatted to0.0.
- European hedgehogweaning, EOL TraitBank
42days, as written; TraitBank’s converted value is 0.11499209429351732 years42 d - Common starlingmass, AVONET
77.099999999999994the spreadsheet’s binary approximation of 77.177.1 g - European robinmass, BIRDBASE
18.116666666666667a computed mean; the column is formatted to two decimals18.12 g - Common ravenmass, AVONET
928the column is formatted to one decimal0.9280 kg
Preserving resolution instead of significant-digit counts
Ptree's quantity layer separates a number's value (kept unrounded for drawing and math) from its recorded display resolution (precision = { resolution, bounds }).
Tracking resolution as a step size in the coordinate's unit, rather than as a significant-digit count, handles zero cleanly (0.00 has resolution 0.01, while a bare 0 states none) and survives unit conversions. Multiplying a unit multiplies the resolution by the same factor, and temperature offsets leave it unchanged. When Ptree converts a unit, it keeps 15 significant digits, which is the exact decimal precision that every IEEE-754 double round-trips. Under that rule, 44 mm becomes 0.044 m, 2.3 years becomes 840.075 days, and 274.15 K becomes 1 °C, stripping 16th-digit float noise without needing a big-decimal library.
At capture time, Ptree reads the publisher's actual reporting tokens (stored in text columns so trailing zeros survive) and inspects spreadsheet column formats. When every cell in a column shares one fixed-decimal format (0.0 in AVONET, 0.00 in BIRDBASE and eight of TreeTraits' nine traits), that format supplies the column's resolution. Variable formats that change with magnitude, such as SquamBase switching from 0.00 under 25 to 0 above 500, are display rounding and claim no resolution. Excel date formats never state precision either. For TraitBank durations, Ptree reads the raw measurement in its original unit rather than TraitBank's pre-converted years.
Singletons and honest rollup bounds
A subtle bug in log-scale rollups is passing a clade with a single measured species through exp(log(value)), which turns an exact 62035 into 62035.00000000005. Ptree's numeric folds preserve singletons verbatim, keeping both value and resolution intact. An odd median likewise takes its middle record directly without passing through log and exp.
When multiple records roll up into a clade mean, documented rounding half-steps ±eᵢ propagate conservatively as Σ(wᵢ eᵢ) / Σwᵢ. Ptree never claims a √n reduction, because errors from a shared source can be correlated. Unknown input precision stays null rather than turning silently into zero uncertainty. Aggregate quantiles deliberately withhold fabricated confidence intervals while flagging histogram bin width (binned) honestly in the provenance panel.
At display time, one shared numeric formatter chooses the shortest common unit rung across a readout and formats each value to the leading decade of its recorded resolution. Any number with no recorded resolution keeps every digit that it carries. The tree never rounds away a decimal that a scientist actually wrote, and never prints fourteen digits of float garbage that they did not.