Reviewing for numbers that lie
By the end of this lesson you will have every numeric column of your screen checked against the five questions, one yield worked out by hand from the raw JSON and matched against the table, and each conversion fixed in one place.
Lens three, and the one with no error message. Leaks and cost eventually announce themselves. A number in the wrong units renders beautifully, sorts correctly, and is simply false.
Every example below is from a real response captured on 2026-08-25.
The fraction that looks like a percentage
{"code":"NVDA","dividend_yield":0.0002}
Render that as 0.0002% and you are wrong by a factor of a hundred: it is 0.02%. Render it as 0.0002 with a % sign glued on and you have said the same false thing.
What makes this dangerous is that both the wrong and the right answers look plausible on screen. A yield of 0.02% for NVIDIA is correct and unremarkable; 0.0002% is absurd if you think about it, and nobody thinks about it while scanning forty rows.
The rule: whenever a field is a rate, find out once whether it is a fraction or a percentage, write the answer in a comment next to the conversion, and never do that conversion anywhere else.
The floating-point tail
From the same response, Apple's one-day change:
{"code":"AAPL","refund_1d":0.98999999999995,"refund_1d_p":0.32}
That is 0.99, arrived at by subtracting two decimals in binary floating point. It is not an API bug; it is how computers do arithmetic, and every language does it.
Two consequences for review:
Never render a raw float. toFixed(2) at the column, always. Without it a column shows 0.98999999999995 beside 4.07 and the table stops looking like a tool.
Never compare floats for equality. refund_1d === 0.99 is false here. If you must compare, compare a rounded value or use a tolerance.
The number so large it stops being read
{"market_capitalization":5049593888768}
Five trillion, and nobody can see that at a glance. A column of raw market caps is unreadable, and unreadable is a correctness problem: you cannot spot the wrong one.
Format to a unit a person holds in their head — 5.05T, 4.53T — and keep the raw value for sorting. Two representations, one source, and never sort the formatted string: alphabetically "5.05T" comes before "999B", so a descending sort puts the smaller company on top.
Missing is not zero
A company with no reported earnings has no earnings_share. If your render does r.earnings_share.toFixed(2) it throws; if it does (r.earnings_share ?? 0).toFixed(2) it prints 0.00, which is a claim you just invented. Zero earnings and unknown earnings are different facts, and a screener that conflates them will rank an unknown as if it earned exactly nothing — above every loss-maker and below every profitable name, a position it has no evidence for.
A dash. Always a dash. That is why render returns string | null in One table, two products.
A zero the API really sends is a different fact. Berkshire pays no dividend and its dividend_yield is 0, so 0.00% is correct for it. A dash is for a value that is null or absent; do not turn real zeros into dashes either.
Two currencies in one column
The response carries currency_symbol. A screen across exchanges returns prices in different currencies, and a column that shows the number without the symbol invites a comparison that means nothing. Sorting by such a column is worse: it ranks by an arbitrary mix of scales.
Either keep one currency per screen, or show the symbol on every row and refuse to sort on it. Silent totalling of mixed units is the same error as the pence trap in Build Your First Tool, one level up.
The lens, as five questions
- Is this a rate, and is it a fraction or a percentage?
- Is this a raw float, and where is the rounding?
- Is this big enough to be unreadable, and is sorting done on the raw value?
- Can this be missing, and does missing render as a dash rather than zero?
- Could two rows here be in different units?
The finance behind it
Two currencies in one column is a quoting question before it is a code question: When you buy EUR/USD, what are you actually buying?
Try it now
Run a screen returning as many rows as you can, twenty if your plan includes the screener (limit 20, one load, five calls) or the ten invented rows of your fixture on mock, and check every numeric column against the five questions.
The prompt
Mock mode on, plan mode on, and paste:
Check every numeric column in src/lib/screen-columns.ts against five
questions: is it a rate, and a fraction or a percentage; where is the
rounding; is it too big to read, and does sorting still use the raw
value; can it be missing, and does missing render as a dash; can two
rows be in different currencies. Answer per column, with the line.
Then fix what fails, with the helpers in a new src/lib/format.ts (call
the fraction-to-percentage helper asPercent), one place per conversion
and a comment saying why. Show me one fixture row
before and after. No new request. Done means npm test, typecheck, lint
and check:leak green; show me the diff.
A good answer adds src/lib/format.ts (asPercent, a compact formatter for market cap, two-decimal rounding) and changes src/lib/screen-columns.ts to call it. The tests come in the next lesson; if your agent already wrote some because the starter asks for a test with every behaviour change, the next lesson rewrites them so that each expectation is a literal.
Check it yourself
- No numeric cell shows more than two decimals: give one fixture row a
refund_1d_pof-2.90999999999995and its change cell shows -2.91, not the tail. - Market cap reads like 5.05T, and a descending market-cap screen still puts the largest company first.
- A row with no
earnings_shareshows a dash, not 0.00. - Every money column carries its currency, or every screen is pinned to one exchange and says so.
Break it on purpose
Do the decisive test: pick the row with the smallest dividend yield, work out the real percentage by hand from the raw JSON, and compare it with what your table shows. If they differ, you have shipped the hundred-times error, and you are in good company.
Compare with ours
// src/lib/format.ts: one place per conversion
// dividend_yield arrives as a fraction: 0.0002 is 0.02%.
export const asPercent = (fraction: number) => `${(fraction * 100).toFixed(2)}%`;
// Display only: 5049593888768 reads 5.05T. Sort on the raw number, never on this.
export function compact(n: number): string {
for (const [size, unit] of [[1e12, "T"], [1e9, "B"], [1e6, "M"]] as const) {
if (Math.abs(n) >= size) return `${(n / size).toFixed(2)}${unit}`;
}
return n.toFixed(2);
}
The full state at the end of this unit is on the starter's branch ref/build-a-screener/u3.
Checkpoint
npm test && npm run typecheck
git status # only the files this step touched, no .env*
git add -A
git commit -m "Screen columns tell the truth: yield in per cent, two decimals, readable caps, dash for missing"
Then answer this lesson's questions.