Skip to content

[POI-66083 & POI-66094] Support (FLOOR|CEILING).MATH & (VAR|STDEV).(P|S) functions#1135

Merged
tonyqus merged 13 commits into
nissl-lab:masterfrom
karakasa:more_supported_functions
Aug 29, 2023
Merged

[POI-66083 & POI-66094] Support (FLOOR|CEILING).MATH & (VAR|STDEV).(P|S) functions#1135
tonyqus merged 13 commits into
nissl-lab:masterfrom
karakasa:more_supported_functions

Conversation

@karakasa
Copy link
Copy Markdown
Contributor

@karakasa karakasa commented Jul 27, 2023

#1023

  1. Added (FLOOR|CEILING).MATH support, and functions are registered through NPOI.SS.Formula.Atp. The algorithm is different from that of POI, incl. a workaround due to CLR lacking BigDecimal.
  2. Added (VAR|STDEV).(P|S) support with implementations based on MSO's webpage.
  3. Added tests and corresponding spreadsheets.

The added MATH functions are superior to the existing FLOOR|CEILING in NPOI because the latter don't have a mechanism of precision control. Porting BigDecimal may be the ultimate answer as what is done in the apache/poi.

I also found a bug in Excel (16717.20000) that produces wrong answer. See AF13 in the last two sheets, the answer should be 4 while Excel reports 2.

@karakasa karakasa changed the title Added support for FLOOR|CEILING.MATH function in formula Support FLOOR|CEILING.MATH functions Jul 27, 2023
@karakasa karakasa changed the title Support FLOOR|CEILING.MATH functions Support (FLOOR|CEILING).MATH & (VAR|STDEV).(P|S) functions Jul 28, 2023
@tonyqus tonyqus added this to the NPOI 2.7.0 milestone Aug 3, 2023
@tonyqus tonyqus added the formula label Aug 3, 2023
@tonyqus
Copy link
Copy Markdown
Member

tonyqus commented Aug 3, 2023

Definitely, BigDecimal is the best choice for high precision calculation. I don't recommend we implement it again. Instead, we can use exisitng nuget packages.

There are some existing implementation on nuget
https://www.nuget.org/packages/dmath.core
https://www.nuget.org/packages/Singulink.Numerics.BigDecimal
https://www.nuget.org/packages/ExtendedNumerics.BigDecimal

Although ExtendedNumerics.BigDecimal doesn't have huge downloads, the author is actively working on this library.

@karakasa
Copy link
Copy Markdown
Contributor Author

karakasa commented Aug 6, 2023

ok. Since you think an external BigDecimal-like lib should be used, I would refactor impls of (FLOOR|CEILING).MATH.

@karakasa karakasa marked this pull request as draft August 7, 2023 07:21
@karakasa

This comment was marked as outdated.

@karakasa karakasa marked this pull request as ready for review August 20, 2023 15:39
@tonyqus
Copy link
Copy Markdown
Member

tonyqus commented Aug 29, 2023

LGTM

@tonyqus tonyqus merged commit 5dbc156 into nissl-lab:master Aug 29, 2023
@karakasa karakasa deleted the more_supported_functions branch August 29, 2023 13:26
@tonyqus tonyqus changed the title Support (FLOOR|CEILING).MATH & (VAR|STDEV).(P|S) functions [POI-66083 & POI-66094] Support (FLOOR|CEILING).MATH & (VAR|STDEV).(P|S) functions May 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants