mirror of
https://github.com/GNOME/libxml2.git
synced 2025-02-23 18:29:14 +08:00
Richard Jinks also raised some rounding problems this tries to fix them
* xpath.c: Richard Jinks also raised some rounding problems this tries to fix them Daniel
This commit is contained in:
parent
4e2df54bb1
commit
56cd18b977
@ -1,3 +1,8 @@
|
|||||||
|
Fri Mar 22 15:13:49 CET 2002 Daniel Veillard <daniel@veillard.com>
|
||||||
|
|
||||||
|
* xpath.c: Richard Jinks also raised some rounding problems
|
||||||
|
this tries to fix them
|
||||||
|
|
||||||
Fri Mar 22 13:22:09 CET 2002 Daniel Veillard <daniel@veillard.com>
|
Fri Mar 22 13:22:09 CET 2002 Daniel Veillard <daniel@veillard.com>
|
||||||
|
|
||||||
* xpath.c: Richard Jinks spotted an incoherent memory allocation
|
* xpath.c: Richard Jinks spotted an incoherent memory allocation
|
||||||
|
43
xpath.c
43
xpath.c
@ -6483,15 +6483,19 @@ xmlXPathSumFunction(xmlXPathParserContextPtr ctxt, int nargs) {
|
|||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
xmlXPathFloorFunction(xmlXPathParserContextPtr ctxt, int nargs) {
|
xmlXPathFloorFunction(xmlXPathParserContextPtr ctxt, int nargs) {
|
||||||
|
double f;
|
||||||
|
|
||||||
CHECK_ARITY(1);
|
CHECK_ARITY(1);
|
||||||
CAST_TO_NUMBER;
|
CAST_TO_NUMBER;
|
||||||
CHECK_TYPE(XPATH_NUMBER);
|
CHECK_TYPE(XPATH_NUMBER);
|
||||||
#if 0
|
|
||||||
ctxt->value->floatval = floor(ctxt->value->floatval);
|
f = (double)((int) ctxt->value->floatval);
|
||||||
#else
|
if (f != ctxt->value->floatval) {
|
||||||
/* floor(0.999999999999) => 1.0 !!!!!!!!!!! */
|
if (ctxt->value->floatval > 0)
|
||||||
ctxt->value->floatval = (double)((int) ctxt->value->floatval);
|
ctxt->value->floatval = f;
|
||||||
#endif
|
else
|
||||||
|
ctxt->value->floatval = f - 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -6516,8 +6520,12 @@ xmlXPathCeilingFunction(xmlXPathParserContextPtr ctxt, int nargs) {
|
|||||||
ctxt->value->floatval = ceil(ctxt->value->floatval);
|
ctxt->value->floatval = ceil(ctxt->value->floatval);
|
||||||
#else
|
#else
|
||||||
f = (double)((int) ctxt->value->floatval);
|
f = (double)((int) ctxt->value->floatval);
|
||||||
if (f != ctxt->value->floatval)
|
if (f != ctxt->value->floatval) {
|
||||||
ctxt->value->floatval = f + 1;
|
if (ctxt->value->floatval > 0)
|
||||||
|
ctxt->value->floatval = f + 1;
|
||||||
|
else
|
||||||
|
ctxt->value->floatval = f;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -6546,15 +6554,18 @@ xmlXPathRoundFunction(xmlXPathParserContextPtr ctxt, int nargs) {
|
|||||||
(ctxt->value->floatval == 0.0))
|
(ctxt->value->floatval == 0.0))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
#if 0
|
|
||||||
f = floor(ctxt->value->floatval);
|
|
||||||
#else
|
|
||||||
f = (double)((int) ctxt->value->floatval);
|
f = (double)((int) ctxt->value->floatval);
|
||||||
#endif
|
if (ctxt->value->floatval < 0) {
|
||||||
if (ctxt->value->floatval < f + 0.5)
|
if (ctxt->value->floatval < f - 0.5)
|
||||||
ctxt->value->floatval = f;
|
ctxt->value->floatval = f - 1;
|
||||||
else
|
else
|
||||||
ctxt->value->floatval = f + 1;
|
ctxt->value->floatval = f;
|
||||||
|
} else {
|
||||||
|
if (ctxt->value->floatval < f + 0.5)
|
||||||
|
ctxt->value->floatval = f;
|
||||||
|
else
|
||||||
|
ctxt->value->floatval = f + 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
|
Loading…
Reference in New Issue
Block a user