[Prev][Next][Index][Thread]

Re: reading a float?



On Fri, 21 Apr 2000 06:11:39 +1000, Sean Case <gsc@zip.com.au> wrote:

>In article <brucehoult-2104000026580001@bruce.bgh>, 
>brucehoult@pobox.com (Bruce Hoult) wrote:
>
>> 1) punt and do whatever the C library on the given platform does
>
>[...]
>
>> It's hard to see how you can go past 1).  Doing this properly is actually
>> far harder than I've intimated above -- people actually write academic
>> papers on the subject.  Someone's already done the hard work of getting
>> fast, accurate FP conversions to work on any machine that has a C
>> compiler.    Why not use it?
>
>Because they probably haven't done a very good job of making it accurate.

Or even making it work. One crash (access violation) I had to trace
turned out to be the MSVC 5.0 library's way of handling 

23410610536448.0000000

I can't offhand remember if I invoked atof or let iostream do it ... but
I was a little startled to find something like that in a standard
library. (I mean, it _is_ a little long, but the documentation didn't
say that'd be a problem... )

>This strongly suggests that there are commercial C
>compiler/library combinations where converting float -> string -> float
>is not even idempotent, let alone an identity.

That's putting it mildly.

- Brian




References: