MCPcopy Create free account
hub / github.com/Kitware/VTK / xmlXPathCastNumberToString

Function xmlXPathCastNumberToString

ThirdParty/libxml2/vtklibxml2/xpath.c:4698–4723  ·  view source on GitHub ↗

* xmlXPathCastNumberToString: * @val: a number * * Converts a number to its string value. * * Returns a newly allocated string. */

Source from the content-addressed store, hash-verified

4696 * Returns a newly allocated string.
4697 */
4698xmlChar *
4699xmlXPathCastNumberToString (double val) {
4700 xmlChar *ret;
4701 switch (xmlXPathIsInf(val)) {
4702 case 1:
4703 ret = xmlStrdup((const xmlChar *) "Infinity");
4704 break;
4705 case -1:
4706 ret = xmlStrdup((const xmlChar *) "-Infinity");
4707 break;
4708 default:
4709 if (xmlXPathIsNaN(val)) {
4710 ret = xmlStrdup((const xmlChar *) "NaN");
4711 } else if (val == 0) {
4712 /* Omit sign for negative zero. */
4713 ret = xmlStrdup((const xmlChar *) "0");
4714 } else {
4715 /* could be improved */
4716 char buf[100];
4717 xmlXPathFormatNumber(val, buf, 99);
4718 buf[99] = 0;
4719 ret = xmlStrdup((const xmlChar *) buf);
4720 }
4721 }
4722 return(ret);
4723}
4724
4725/**
4726 * xmlXPathCastNodeToString:

Callers 2

xmlXPathCastToStringFunction · 0.85
xmlXPathConvertStringFunction · 0.85

Calls 4

xmlXPathIsInfFunction · 0.85
xmlStrdupFunction · 0.85
xmlXPathIsNaNFunction · 0.85
xmlXPathFormatNumberFunction · 0.85

Tested by

no test coverage detected