diff options
author | Tanner Gooding <tagoo@outlook.com> | 2019-01-30 15:35:07 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-30 15:35:07 -0800 |
commit | dbb42159bba3d147559032ee496b55aa7e94e6f7 (patch) | |
tree | df68a0e32b78959a1492e9a6116e34a1bed54015 /src/System.Private.CoreLib/shared/System/Buffers/Text/Utf8Formatter/Utf8Formatter.Decimal.cs | |
parent | f52a3f595f9067d957a9b77d72689b8f564657f3 (diff) | |
download | coreclr-dbb42159bba3d147559032ee496b55aa7e94e6f7.tar.gz coreclr-dbb42159bba3d147559032ee496b55aa7e94e6f7.tar.bz2 coreclr-dbb42159bba3d147559032ee496b55aa7e94e6f7.zip |
Reverting "Fixing up the UTF8Formatter and some tests to properly handle -0.0" (#22300)
Diffstat (limited to 'src/System.Private.CoreLib/shared/System/Buffers/Text/Utf8Formatter/Utf8Formatter.Decimal.cs')
-rw-r--r-- | src/System.Private.CoreLib/shared/System/Buffers/Text/Utf8Formatter/Utf8Formatter.Decimal.cs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/System.Private.CoreLib/shared/System/Buffers/Text/Utf8Formatter/Utf8Formatter.Decimal.cs b/src/System.Private.CoreLib/shared/System/Buffers/Text/Utf8Formatter/Utf8Formatter.Decimal.cs index e44589ccb4..bb93b992ef 100644 --- a/src/System.Private.CoreLib/shared/System/Buffers/Text/Utf8Formatter/Utf8Formatter.Decimal.cs +++ b/src/System.Private.CoreLib/shared/System/Buffers/Text/Utf8Formatter/Utf8Formatter.Decimal.cs @@ -47,6 +47,10 @@ namespace System.Buffers.Text Number.NumberBuffer number = new Number.NumberBuffer(Number.NumberBufferKind.Decimal, pDigits, Number.DecimalNumberBufferLength); Number.DecimalToNumber(ref value, ref number); + if (number.Digits[0] == 0) + { + number.IsNegative = false; // For Decimals, -0 must print as normal 0. + } bool success = TryFormatDecimalG(ref number, destination, out bytesWritten); #if DEBUG // This DEBUG segment exists to close a code coverage hole inside TryFormatDecimalG(). Because we don't call RoundNumber() on this path, we have no way to feed @@ -91,6 +95,7 @@ namespace System.Buffers.Text Number.DecimalToNumber(ref value, ref number); byte precision = (format.Precision == StandardFormat.NoPrecision) ? (byte)2 : format.Precision; Number.RoundNumber(ref number, number.Scale + precision); + Debug.Assert((number.Digits[0] != 0) || !number.IsNegative); // For Decimals, -0 must print as normal 0. As it happens, Number.RoundNumber already ensures this invariant. return TryFormatDecimalF(ref number, destination, out bytesWritten, precision); } @@ -103,6 +108,7 @@ namespace System.Buffers.Text Number.DecimalToNumber(ref value, ref number); byte precision = (format.Precision == StandardFormat.NoPrecision) ? (byte)6 : format.Precision; Number.RoundNumber(ref number, precision + 1); + Debug.Assert((number.Digits[0] != 0) || !number.IsNegative); // For Decimals, -0 must print as normal 0. As it happens, Number.RoundNumber already ensures this invariant. return TryFormatDecimalE(ref number, destination, out bytesWritten, precision, exponentSymbol: (byte)format.Symbol); } |