15 points | by signa11 2 days ago
5 comments
Even putting aside the ugliness of errno, this is pretty bad. I'm at the point with libc where I try to use as little of it as I can, though I'm not writing a lot of C these days
IEEE-754 is a harsh mistress.
https://en.wikipedia.org/wiki/IEEE_754
The VAX floating point was advanced as an alternative standards proposal at that time. Intel won the argument.
https://sixlettervariable.blogspot.com/2007/05/vax-floating-...
if (sscanf(string,"%lf",&foo) != 1) { bad_float(); }
For extra reassurance, initialize foo to NaN or DBL_MAX or something, and verify that it is no longer equal to that value.
yes. that's why many number crunching app ships / vendors their own math library
Even putting aside the ugliness of errno, this is pretty bad. I'm at the point with libc where I try to use as little of it as I can, though I'm not writing a lot of C these days
IEEE-754 is a harsh mistress.
https://en.wikipedia.org/wiki/IEEE_754
The VAX floating point was advanced as an alternative standards proposal at that time. Intel won the argument.
https://sixlettervariable.blogspot.com/2007/05/vax-floating-...
For extra reassurance, initialize foo to NaN or DBL_MAX or something, and verify that it is no longer equal to that value.
yes. that's why many number crunching app ships / vendors their own math library