• I use strtod, and I have never had the author’s requirement to detect that a small number has underflowed to 0.

    From my perspective, strtod returns an approximation: the floating point number closest to the number described by the digit string. If the floating point number closest to the numeral is 0, it returns that. I don’t have a use case where choosing 0 as the approximation needs to be handled differently from choosing some other float as the approximation. In what circumstance is this particular case an “error” when returning an approximate non-zero result is not an error?

    I think the author has a specialized need that may not be encountered by most people. In these cases I just use a third party library, as the standard C library doesn’t cover all use cases for which you may need a library function.


    score 1 · canonical