Skip to content

fix(xlsx): round MROUND midpoints away from zero - #227

Open
LeoLin990405 wants to merge 1 commit into
iOfficeAI:mainfrom
LeoLin990405:fix-mround-away-from-zero
Open

fix(xlsx): round MROUND midpoints away from zero#227
LeoLin990405 wants to merge 1 commit into
iOfficeAI:mainfrom
LeoLin990405:fix-mround-away-from-zero

Conversation

@LeoLin990405

Copy link
Copy Markdown

Fixes #219.

Summary

  • Pass MidpointRounding.AwayFromZero when evaluating MROUND.
  • This matches Excel's documented midpoint behavior instead of .NET's default banker's rounding (ToEven).

Validation

  • git diff --check
  • Numerical sanity check:
    • default rounding: 0.5 -> 0, 2.5 -> 2
    • away-from-zero rounding: 0.5 -> 1, 2.5 -> 3

Not run: dotnet publish / CLI smoke, because this local machine does not have a .NET SDK installed.

Excel MROUND rounds midpoint values away from zero, but Math.Round defaults to ToEven. Pass MidpointRounding.AwayFromZero so midpoint multiples such as MROUND(0.5, 1) and MROUND(2.5, 1) match Excel.

Refs iOfficeAI#219.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

# Issue 9: [BUG] MROUND uses banker's rounding (ToEven) instead of Excel's AwayFromZero

1 participant