dotnet / dotnet/csharpstandard
9.2.8 and 12.9.3 Unclear behavior of the operator % for decimals
Open
type: clarity
- Dominant language
- C#
- Stars
- 815
- Forks
- 99
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 16
Description
> 10.2.8 The decimal type
> The result of an operation on values of type decimal is that which would result from calculating an exact result (preserving scale, as defined for each operator) and then rounding to fit the representation.
---
> 13.9.3 Division operator
> The result of x % y is the value produced by x – (x / y) \* y
The question is about evaluation of % operator. Does it evaluate as x – (x / y) \* y using exact arithmetics (no rounding) at all intermediate steps, and then rounds the result once? Or rounding happens during each intermediate step?
Contributor guide
Assessment
This issue has not been assessed yet.