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

   Follow-up to #1275 / #1278–#1285: two more Excel-fidelity gaps found by 
fuzzing every registered function.
   
   ### Infinite numbers
   
   Excel has no infinite numbers, but three entry points let `Infinity` into 
the evaluator:
   
   | Formula | Before | After (Excel) |
   |---|---|---|
   | `=1E400` | cell holds `Infinity` | `#NUM!` |
   | `=VALUE("1E400")` | `Infinity` | `#VALUE!` |
   | `="1E400"+0` | `#NUM!` (Infinity caught downstream) | `#VALUE!` |
   | `=SQRTPI(1E400)`, `=STANDARDIZE(1E400,0,1)` … | `Infinity` / `NaN` cell | 
`#NUM!` |
   | `=FIXED(1E400)`, `=MROUND(1E400,3)`, `=CEILING.MATH(5,1E400)` | 
`NumberFormatException` from `BigDecimal.valueOf` | `#NUM!` |
   | `=CHAR(1E400)`, `=LEFT("abc",1E400)` … | `IllegalArgumentException: Cannot 
convert infinity to int` | `#NUM!` |
   
   - `WorkbookEvaluator`: a `NumberPtg` that is not finite evaluates to `#NUM!` 
(the parser still accepts the literal, as Excel does — it is the evaluation 
that fails).
   - `OperandResolver.parseDouble` and `Value.convertTextToNumber`: an infinite 
parse result is "not a number", so the text falls through to `#VALUE!`.
   
   ### Significance 0
   
   `CEILING.MATH`, `FLOOR.MATH`, `CEILING.PRECISE` and `FLOOR.PRECISE` threw 
`ArithmeticException: Division by zero` for a significance of 0; Excel returns 
0. The four functions now also run their inputs and result through 
`NumericFunction.checkValue`, so an infinite input or a result that overflows a 
double (`=CEILING.MATH(1.7E308,1E308)`) is `#NUM!` rather than an exception or 
an `Infinity` cell.
   
   Tests added for each case; `org.apache.poi.ss.formula.*`, `ss.util.*`, 
`hssf.model.*` 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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to