21 #define strncasecmp _strnicmp 31 pstrtod(
const char *nptr,
char **endptr) {
40 if (*p ==
'+' || *p ==
'-') {
50 if (strncasecmp(p,
"inf", 3) == 0) {
52 if (strncasecmp(p,
"inity", 5) == 0) {
55 value = std::numeric_limits<double>::infinity();
57 }
else if (strncasecmp(p,
"nan", 3) == 0) {
60 if (*p ==
's' || *p ==
'S') {
61 value = std::numeric_limits<double>::signaling_NaN();
64 if (*p ==
'q' || *p ==
'Q') {
67 value = std::numeric_limits<double>::quiet_NaN();
74 if (strncmp(p,
"()", 2) == 0) {
81 return strtod(nptr, endptr);
86 bool found_digits =
false;
88 value = (value * 10.0) + (*p -
'0');
96 double multiplicand = 0.1;
98 value += (*p -
'0') * multiplicand;
107 if (endptr !=
nullptr) {
108 *endptr = (
char *)nptr;
113 if (tolower(*p) ==
'e') {
118 if (*p ==
'+' || *p ==
'-') {
125 while (isdigit(*p)) {
126 evalue = (evalue * 10.0) + (*p -
'0');
131 value /= pow(10.0, evalue);
133 value *= pow(10.0, evalue);
142 if (endptr !=
nullptr) {
double pstrtod(const char *nptr, char **endptr)
This function re-implements strtod, to avoid the problems that occur when the LC_NUMERIC locale gets ...
double patof(const char *str)
This function re-implements atof, to avoid the problems that occur when the LC_NUMERIC locale gets se...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.