summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTanner Gooding <tagoo@outlook.com>2019-01-30 15:35:07 -0800
committerGitHub <noreply@github.com>2019-01-30 15:35:07 -0800
commitdbb42159bba3d147559032ee496b55aa7e94e6f7 (patch)
treedf68a0e32b78959a1492e9a6116e34a1bed54015
parentf52a3f595f9067d957a9b77d72689b8f564657f3 (diff)
downloadcoreclr-dbb42159bba3d147559032ee496b55aa7e94e6f7.tar.gz
coreclr-dbb42159bba3d147559032ee496b55aa7e94e6f7.tar.bz2
coreclr-dbb42159bba3d147559032ee496b55aa7e94e6f7.zip
Reverting "Fixing up the UTF8Formatter and some tests to properly handle -0.0" (#22300)
-rw-r--r--src/System.Private.CoreLib/shared/System/Buffers/Text/Utf8Formatter/Utf8Formatter.Decimal.cs6
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);
}