Nasty bug
Sean Legassick
asrap at warwick.ac.uk
Fri Aug 31 21:57:51 AEST 1990
In article <11473 at crdgw1.crd.ge.com> volpe at underdog.crd.ge.com (Christopher R Volpe) writes:
=In article <0093BF08.7F3834E0 at rigel.efd.lth.se>, e89hse at rigel.efd.lth.se
=writes:
=|>Later I rewrote
=|>prnval() as:
=|>
=|>prnval(s,f)
=|>char *s;
=|>double f;
=|>{
=|> if(f == 0.0)
=|> sscanf(s,"%lf",&f);
=|> printf("%10.2f\n",f);
=|>}
=
=This is the correct solution anyway.
There is still a possible problem though. Comparing floating-point
values to 0 like that can cause problems, especially if the values been
put through the mangle of promotion etc. Its far less likely to cause problems
if you use something like :
if (f < 0.005)
As the orginal poster did not describe the nature of the problem when
the program was run (or compiled) this could have been the cause.
=|>
=|> Henrik Sandell
=
===================
=Chris Volpe
=G.E. Corporate R&D
=volpecr at crd.ge.com
---------------------------------------------------------------------------
Sean Legassick, cuuee at uk.ac.warwick.cu "Improbability factor of one
Computing Services asrap at uk.ac.warwick.cu to one. We have normality.
University of Warwick Anything you still can't
(the walking C obfuscator!) handle is your own problem."
More information about the Comp.lang.c
mailing list