@@ -105,7 +105,7 @@ typedef struct __TypeContext {
105
105
PyObject * attrList ;
106
106
PyObject * iterator ;
107
107
108
- double doubleValue ;
108
+ long double longDoubleValue ;
109
109
JSINT64 longValue ;
110
110
111
111
char * cStr ;
@@ -164,7 +164,7 @@ static TypeContext *createTypeContext(void) {
164
164
pc -> index = 0 ;
165
165
pc -> size = 0 ;
166
166
pc -> longValue = 0 ;
167
- pc -> doubleValue = 0.0 ;
167
+ pc -> longDoubleValue = ( long double ) 0.0 ;
168
168
pc -> cStr = NULL ;
169
169
pc -> npyarr = NULL ;
170
170
pc -> pdblock = NULL ;
@@ -1494,8 +1494,8 @@ void Object_beginTypeContext(JSOBJ _obj, JSONTypeContext *tc) {
1494
1494
if (npy_isnan (val ) || npy_isinf (val )) {
1495
1495
tc -> type = JT_NULL ;
1496
1496
} else {
1497
- pc -> doubleValue = val ;
1498
- tc -> type = JT_DOUBLE ;
1497
+ pc -> longDoubleValue = ( long double ) val ;
1498
+ tc -> type = JT_LONG_DOUBLE ;
1499
1499
}
1500
1500
return ;
1501
1501
} else if (PyBytes_Check (obj )) {
@@ -1507,8 +1507,8 @@ void Object_beginTypeContext(JSOBJ _obj, JSONTypeContext *tc) {
1507
1507
tc -> type = JT_UTF8 ;
1508
1508
return ;
1509
1509
} else if (object_is_decimal_type (obj )) {
1510
- pc -> doubleValue = PyFloat_AsDouble (obj );
1511
- tc -> type = JT_DOUBLE ;
1510
+ pc -> longDoubleValue = ( long double ) PyFloat_AsDouble (obj );
1511
+ tc -> type = JT_LONG_DOUBLE ;
1512
1512
return ;
1513
1513
} else if (PyDateTime_Check (obj ) || PyDate_Check (obj )) {
1514
1514
if (object_is_nat_type (obj )) {
@@ -1605,10 +1605,12 @@ void Object_beginTypeContext(JSOBJ _obj, JSONTypeContext *tc) {
1605
1605
PyArray_DescrFromType (NPY_BOOL ));
1606
1606
tc -> type = (pc -> longValue ) ? JT_TRUE : JT_FALSE ;
1607
1607
return ;
1608
- } else if (PyArray_IsScalar (obj , Float ) || PyArray_IsScalar (obj , Double )) {
1609
- PyArray_CastScalarToCtype (obj , & (pc -> doubleValue ),
1610
- PyArray_DescrFromType (NPY_DOUBLE ));
1611
- tc -> type = JT_DOUBLE ;
1608
+ } else if (PyArray_IsScalar (obj , Float ) ||
1609
+ PyArray_IsScalar (obj , Double ) ||
1610
+ PyArray_IsScalar (obj , LongDouble )) {
1611
+ PyArray_CastScalarToCtype (obj , & (pc -> longDoubleValue ),
1612
+ PyArray_DescrFromType (NPY_LONGDOUBLE ));
1613
+ tc -> type = JT_LONG_DOUBLE ;
1612
1614
return ;
1613
1615
} else if (PyArray_Check (obj ) && PyArray_CheckScalar (obj )) {
1614
1616
PyErr_Format (PyExc_TypeError ,
@@ -1925,8 +1927,8 @@ JSINT64 Object_getLongValue(JSOBJ Py_UNUSED(obj), JSONTypeContext *tc) {
1925
1927
return GET_TC (tc )-> longValue ;
1926
1928
}
1927
1929
1928
- double Object_getDoubleValue (JSOBJ Py_UNUSED (obj ), JSONTypeContext * tc ) {
1929
- return GET_TC (tc )-> doubleValue ;
1930
+ long double Object_getLongDoubleValue (JSOBJ Py_UNUSED (obj ), JSONTypeContext * tc ) {
1931
+ return GET_TC (tc )-> longDoubleValue ;
1930
1932
}
1931
1933
1932
1934
const char * Object_getBigNumStringValue (JSOBJ obj , JSONTypeContext * tc ,
@@ -1970,7 +1972,6 @@ PyObject *objToJSON(PyObject *Py_UNUSED(self), PyObject *args,
1970
1972
if (PyDateTimeAPI == NULL ) {
1971
1973
return NULL ;
1972
1974
}
1973
-
1974
1975
PandasDateTime_IMPORT ;
1975
1976
if (PandasDateTimeAPI == NULL ) {
1976
1977
return NULL ;
@@ -2006,7 +2007,7 @@ PyObject *objToJSON(PyObject *Py_UNUSED(self), PyObject *args,
2006
2007
Object_getStringValue ,
2007
2008
Object_getLongValue ,
2008
2009
NULL , // getIntValue is unused
2009
- Object_getDoubleValue ,
2010
+ Object_getLongDoubleValue ,
2010
2011
Object_getBigNumStringValue ,
2011
2012
Object_iterBegin ,
2012
2013
Object_iterNext ,
0 commit comments