FA-97008 / Recipe scaling and nutrition / Member archive
Percent daily value formatter: unit normalization · case 03
0.5 g of sodium is reported as 0.02% instead of 22%.
Case contract
DVs: sodium 2300 mg, fat 78 g, fiber 28 g, calcium 1300 mg, vitamin d 20 mcg, added sugars 50 g, protein 50 g. Names are trimmed, case-insensitive; unknown -> "error: no daily value". Units g, mg, mcg convert exactly; "iu" is allowed only for vitamin d (40 IU = 1 mcg), else "error: unit". pct = amount/DV*100. Zero -> "0%". Calcium and vitamin d: <2 -> "<2%", <=10 -> nearest 2, <=50 -> nearest 5, else nearest 10. Others: <1 -> "<1%", else nearest 1. Half-up.
Why this case matters
Label software prints %DV with different increments for micronutrients and macronutrients.
One recorded failure
Sample boundary fixtureThis sample comes from the broken implementation of a controlled reproducer.
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression: unit normalization | "13%" | "\u003c1%" | Failed |
MEMBER ARCHIVE
The complete case is available to members.
This record includes three runnable implementations, regression fixtures, execution results, and source hashes.
Member access is invitation-based. Sign in with your invited account to inspect the sources.
Sign in to the archive ↗