* xmlXPathCastNumberToString: * @val: a number * * Converts a number to its string value. * * Returns a newly allocated string. */
| 4696 | * Returns a newly allocated string. |
| 4697 | */ |
| 4698 | xmlChar * |
| 4699 | xmlXPathCastNumberToString (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: |
no test coverage detected