On Thu, Mar 26, 2009 at 11:41 AM, Greg Chicares <gchica...@sbcglobal.net> wrote: > On 2009-03-26 16:27Z, Gregg Reynolds wrote: > [...] >> #define strtold(a,b) ((long double)strtod((a),(b))) >> >> make check fails on >> >> tchtest write casket 50000 5000 5 5 > > Does that test depend on accurate long-double i/o, > which the strtod() kludge sacrifices? >
It uses it, but I don't know if it actually needs the long double. I suppose it does, considering it's part of a test suite. ;) Here's the code that uses strtold: /* Convert a string with a metric prefix to an integer. */ int64_t tcatoix(const char *str){ assert(str); char *end; #define strtold(a,b) ((long double)strtod((a),(b))) /*gar*/ long double val = strtold(str, &end); int inf = isinf(val); if(inf != 0) return inf > 0 ? INT64_MAX : INT64_MIN; if(!isnormal(val)) return 0; if(*end == 'k' || *end == 'K'){ val *= 1LL << 10; } else if(*end == 'm' || *end == 'M'){ val *= 1LL << 20; } else if(*end == 'g' || *end == 'G'){ val *= 1LL << 30; } else if(*end == 't' || *end == 'T'){ val *= 1LL << 40; } else if(*end == 'p' || *end == 'P'){ val *= 1LL << 50; } else if(*end == 'e' || *end == 'E'){ val *= 1LL << 60; } if(val > INT64_MAX) return INT64_MAX; if(val < INT64_MIN) return INT64_MIN; return val; } It looks to me like that should work, but then again it's been a while since I dug into serious code. I'm not even sure how isinf is supposed to work. Thanks, gregg -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/