summaryrefslogtreecommitdiff
path: root/src/classlibnative
diff options
context:
space:
mode:
authorTanner Gooding <tagoo@outlook.com>2018-08-30 10:09:59 -0700
committerTanner Gooding <tagoo@outlook.com>2018-09-06 17:07:08 -0700
commitad3c8cc8934ec89631c221713b86238f6c86e1b6 (patch)
treee7005b0c8e6ea5ff367a09246a6edf5a40e162e5 /src/classlibnative
parente80e55a1ace4b4de10072b0f6f71f79aca868906 (diff)
downloadcoreclr-ad3c8cc8934ec89631c221713b86238f6c86e1b6.tar.gz
coreclr-ad3c8cc8934ec89631c221713b86238f6c86e1b6.tar.bz2
coreclr-ad3c8cc8934ec89631c221713b86238f6c86e1b6.zip
Updating Number.Formatting to properly print -0
Diffstat (limited to 'src/classlibnative')
-rw-r--r--src/classlibnative/bcltype/grisu3.cpp4
-rw-r--r--src/classlibnative/bcltype/grisu3.h5
-rw-r--r--src/classlibnative/bcltype/number.cpp2
-rw-r--r--src/classlibnative/bcltype/number.h20
4 files changed, 22 insertions, 9 deletions
diff --git a/src/classlibnative/bcltype/grisu3.cpp b/src/classlibnative/bcltype/grisu3.cpp
index 0fc9e88928..e0138f64e8 100644
--- a/src/classlibnative/bcltype/grisu3.cpp
+++ b/src/classlibnative/bcltype/grisu3.cpp
@@ -44,7 +44,7 @@ bool Grisu3::Run(double value, int count, int* dec, int* sign, wchar_t* digits)
// kappa: A factor used for generating digits. See step 5 of the Grisu3 procedure in the paper.
// Handle sign bit.
- if (value < 0)
+ if (_signbit(value) != 0)
{
value = -value;
*sign = 1;
@@ -378,4 +378,4 @@ void Grisu3::BiggestPowerTenLessThanOrEqualTo(UINT32 number,
*exponent = 0;
UNREACHABLE();
}
-} \ No newline at end of file
+}
diff --git a/src/classlibnative/bcltype/grisu3.h b/src/classlibnative/bcltype/grisu3.h
index b3c5a40efa..7f8ec82811 100644
--- a/src/classlibnative/bcltype/grisu3.h
+++ b/src/classlibnative/bcltype/grisu3.h
@@ -12,6 +12,11 @@
#include "diyfp.h"
+#ifdef _MSC_VER
+#define _signbit signbit
+#define _signbitf signbit
+#endif
+
struct PowerOfTen
{
UINT64 significand;
diff --git a/src/classlibnative/bcltype/number.cpp b/src/classlibnative/bcltype/number.cpp
index b20044ec41..ea63122515 100644
--- a/src/classlibnative/bcltype/number.cpp
+++ b/src/classlibnative/bcltype/number.cpp
@@ -288,7 +288,7 @@ void DoubleToNumberWorker( double value, int count, int* dec, int* sign, wchar_t
if (value == 0.0)
{
*dec = 0;
- *sign = 0;
+ *sign = _signbit(value);
// Instead of zeroing digits, we just make it as an empty string due to performance reason.
*digits = 0;
diff --git a/src/classlibnative/bcltype/number.h b/src/classlibnative/bcltype/number.h
index 22c74cacdb..480e6ad6a0 100644
--- a/src/classlibnative/bcltype/number.h
+++ b/src/classlibnative/bcltype/number.h
@@ -19,13 +19,21 @@ static const double LOG10V2 = 0.30102999566398119521373889472449;
// DRIFT_FACTOR = 1 - LOG10V2 - epsilon (a small number account for drift of floating point multiplication)
static const double DRIFT_FACTOR = 0.69;
+enum NUMBER_KIND : int {
+ NUMBER_KIND_Unknown = 0,
+ NUMBER_KIND_Integer = 1,
+ NUMBER_KIND_Decimal = 2,
+ NUMBER_KIND_Double = 3
+};
+
struct NUMBER {
- int precision;
- int scale;
- int sign;
- wchar_t digits[NUMBER_MAXDIGITS + 1];
- wchar_t* allDigits;
- NUMBER() : precision(0), scale(0), sign(0), allDigits(NULL) {}
+ int precision; // 0
+ int scale; // 4
+ int sign; // 8
+ NUMBER_KIND kind; // 12
+ wchar_t* allDigits; // 16
+ wchar_t digits[NUMBER_MAXDIGITS + 1]; // 20 or 24
+ NUMBER() : precision(0), scale(0), sign(0), kind(NUMBER_KIND_Unknown), allDigits(NULL) {}
};
class COMNumber