You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by "pjfanning (via GitHub)" <gi...@apache.org> on 2026/09/18 14:25:11 UTC

[PR] Flush subnormal numbers to zero in NumberEval, so every formula path agrees with Excel [poi]

pjfanning opened a new pull request, #1295:
URL: https://github.com/apache/poi/pull/1295

   #1275 made `*` and `/` return 0 for a result below `Double.MIN_NORMAL` (Excel has no subnormal numbers), but nothing else did: the literal `1E-308`, `ABS(1E-308)`, `RADIANS(1E-307)`, `EXP(-709)`, `POWER(1E-200,2)`, `GEOMEAN`, `PMT`, `NPV`, … still stored a subnormal in the cell (displayed as `0`, but not equal to 0).
   
   The flush now lives in the two `NumberEval` constructors, the one place every number result passes through: a value with `0 < |value| < Double.MIN_NORMAL` becomes `+0.0`, from a literal, a cell or a function alike. The sign of an actual zero is untouched (`TestMinusZeroResult` still passes), and a negative subnormal becomes `+0` like every other underflow in #1275.
   
   Knock-on, and as in Excel: a subnormal divisor is a zero divisor, so `=1/1E-308` and `=MOD(1,1E-308)` are `#DIV/0!`. Two existing assertions that divided by `Double.MIN_VALUE`/`1E-308` to provoke `#NUM!` now use `1E300/1E-300`, and `TestMinusZeroResult` drops its "sub-normal negative numbers display as -0" case since such a number no longer reaches the renderer.
   
   Tests: new `TestNumberEval`; `org.apache.poi.ss.formula.*`, `ss.util.*` and the HSSF formula tests pass.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


Re: [PR] Flush subnormal numbers to zero in NumberEval, so every formula path agrees with Excel [poi]

Posted by "pjfanning (via GitHub)" <gi...@apache.org>.
pjfanning merged PR #1295:
URL: https://github.com/apache/poi/pull/1295


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org