You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by Vladislav Galas <ga...@apache.org> on 2019/01/02 15:20:21 UTC

Re: FormulaEvaluator float presicion problem


On 2018/10/09 12:39:39, "pj.fanning" <fa...@yahoo.com> wrote: 
> Could you try using DataFormatter after using the FormulaEvaluator?
> 
> https://stackoverflow.com/questions/21538481/xssf-how-to-get-anything-as-string/21550258#21550258
> 
> 
> 
> --
> Sent from: http://apache-poi.1045710.n5.nabble.com/POI-Dev-f2312866.html
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
> For additional commands, e-mail: dev-help@poi.apache.org
> 
> 

The problem is deeper. Excel claims to be IEEE754 compatible but in fact coerces doubles to significant 15 digits at least before writing a value to a cell. When operands have differend magnitude, the highest order of magnitude is tracked, and lesser operands are coerced to that magnitude. Therefore, the output is not strictly IEEE754 compatible. 
To handle this in my private fork, I passed a PrecisionContext to all operations, tracked magnitude of operands and coerced the result through BigDecimal. But this is a significant change to the evaluation process, and I am not ready to present this fix right away.

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