5 comments

  • chasil 50 minutes ago
    IEEE-754 is a harsh mistress.

    https://en.wikipedia.org/wiki/IEEE_754

  • anitil 43 minutes ago
    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
    • signa11 1 minute ago
      well, unless you are 'syscalling' someone else is doing it on your behalf.
  • j16sdiz 1 hour ago
    yes. that's why many number crunching app ships / vendors their own math library
  • TZubiri 27 minutes ago
    " Dinesh: I said I would do DRM you would do error handling.

    Gilfoyle: Anything to do with errors is more your vibe"

    https://www.youtube.com/watch?v=oyVksFviJVE&t=49

    Oh, this one is easy.

    Just don't make the errors, then you don't have to detect them.

    When your app stops issuing these errors, then you won't have to write blog posts complaining that someone elses code can't handle your errors.

    Definitely you should never be converting strings to floats ever anyways, see how I'm going on a limb here without any knowledge of your application, but then you know that I'm right because there's no reason why you would ever do that?

  • CamperBob2 46 minutes ago

         if (sscanf(string,"%lf",&foo) != 1) 
            { 
            bad_float(); 
            }
    
    This has the benefit of handling scientific notation, too, which some of the other CRTL functions inexplicably do not.

    For extra reassurance, initialize foo to NaN or DBL_MAX or something, and verify that it is no longer equal to that value.

    • shakna 6 minutes ago
      sscanf has locale things that make it include implementation-defined behaviour, doesn't it?