Re: Looking for a Better atof()

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Joseph M. Newcomer (newcomer_at_flounder.com)
Date: 03/09/04


Date: Mon, 08 Mar 2004 21:41:20 -0500

For a "better floating point", there is a simple fix: code your own that simply validates
the syntax of the floating point number. When you know it is correct, you call the
standard C routine.

There is a floating-point parser that does exactly this checking shown in my Validating
Edit Control on my MVP Tips site.
                                joe

On Mon, 8 Mar 2004 14:57:29 -0700, "Jonathan Wood" <jwood@softcircuits.com> wrote:

>Does anyone know of any code for a better atof() routine?
>
>Specifically, I'm looking for code that will report bad characters or
>out-of-range strings. I'm looking for the same thing for int, _int64, float,
>and single as well. I can code my own for integers but just don't know where
>to start for floating point. (It appears routines like atof() simply return
>0.0 if the string is invalid, but 0.0 could also be a valid result.)
>
>Any tips appreciated!

Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm



Relevant Pages

  • Re: Looking for a Better atof()
    ... avoid parsing the string twice. ... > the syntax of the floating point number. ... > standard C routine. ... > Edit Control on my MVP Tips site. ...
    (microsoft.public.vc.mfc)
  • Re: Math computing time statistics for ARM7TDMI and MSP430
    ... I wanted to play with writing a floating point routine ... Probably because you didn't support all the IEEE 754 exception/rounding ... extra is done in compiler libraries. ...
    (comp.arch.embedded)
  • Re: Floating Point: Binary Shift Subroutine
    ... code All's going well, but ran into this routine. ... I wrote a test program to call the old routine and it ... looks like it is a double precision floating point. ... test program which uses reasonable variable types. ...
    (comp.lang.fortran)
  • Re: floating point question on MSP430
    ... If that's the only reason you need to include floating point ... > perform 1 square root per event. ... Writing a routine that sets a bit and then squares it & ... In a later post you state that you are using a compiler. ...
    (comp.arch.embedded)
  • Re: Rounding of the double
    ... But at least part of your problem arises because you aren't formatting the floating point ... And this is not matter of a display. ... As Joe says "there is no accurate representation of 0.80 in IEEE floating ... MVP Tips:http://www.flounder.com/mvp_tips.htm- Hide quoted text - ...
    (microsoft.public.vc.mfc)