KITFORMA · EDITORIAL ANSWER
Why does a BigDecimal created from 0.1 contain unexpected digits?
KitForma editorial guide. The decimal constructor cannot recover a value that was already approximated in a binary floating-point variable. Choose the representation at the input boundary.
Step-by-step answer
new BigDecimal("0.10") rather than passing a double literal. When a double is genuinely the input contract, BigDecimal.valueOf(value) uses its decimal string representation, but that still cannot reconstruct earlier arithmetic intent. Keep calculations in BigDecimal and choose rounding where the business rule actually requires it.
Check a small synthetic invoice: three units at 0.10 should compare numerically to 0.30. Include zero and negative adjustments. Decimal arithmetic alone does not define tax rules or currency rounding; validate those rules separately.Sources and verification
Sources checked:
Scope: This editorial guide is based on the cited sources and tool behavior. A forum question or a query observed for our site does not establish market search volume, low competition, guaranteed rankings or inadequate answers elsewhere.
This editorial answer was prepared by KitForma with AI assistance. It is not presented as a real member question or an independent user review. Check the sources and the result with your own file; report corrections in the discussion.