Number formatting rounding discrepancy
- Dominant language
- No language data
- Stars
- 4.8k
- Forks
- 6.1k
- Avg merge
- 19h 10m
- Merged PRs (30d)
- 268
Description
[Enter feedback here]
Tested on .net core runtime 3.1.10
double num = 1234.5;
var str = num.ToString("G4"); (1234, the rounding is using MidpointRounding.ToEven which is the expected behavior)
double money = 12.345;
var moneyStr = money .ToString("C"); ($12.35, the rounding is using MidpointRounding.AwayFromZero, the result is expected to be $12.34 since formatting should be using MidpointRounding.ToEven)
decimal num2 = 1234.5m;
var str2 = num2.ToString("G4"); (1235, the rounding is using MidpointRounding.AwayFromZero, the result is expected to be 1234 since formatting should be using MidpointRounding.ToEven)
---
#### Document Details
⚠ *Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.*
* ID: 0ae38fce-fc98-9420-6b0b-ceee4e885f2d
* Version Independent ID: f23035e0-f271-b48c-f9a9-8582be80b4ad
* Content: [Standard numeric format strings](https://docs.microsoft.com/en-us/dotnet/standard/base-types/standard-numeric-format-strings#feedback)
* Content Source: [docs/standard/base-types/standard-numeric-format-strings.md](https://github.com/dotnet/docs/blob/master/docs/standard/base-types/standard-numeric-format-strings.md)
* Product: **dotnet-fundamentals**
* GitHub Login: @adegeo
* Microsoft Alias: **adegeo**
Contributor guide
Assessment
This issue has not been assessed yet.