Problems post sprintf->snprintf conversion
Russ Allbery
rra at stanford.edu
Thu Aug 22 02:20:09 UTC 2002
Alex Kiernan <alexk at demon.net> writes:
> The floating point formatting in the snprintf replacement breaks when
> you try and print something larger than MAXINT, quietly, in a hard to
> debug way :( Given INN uses floats to get around just this problem,
> this is really, really scary.
> The code does:
> intpart = ufvalue;
> where ufvalue is the absolute part of the floating point number. The
> conversion then proceeds based on intpart and fvalue - inpart (for the
> fractional part). I can't remember what the standard says such
> conversion overflows should do, Sun C seems to give you MAXINT.
Bleh.
Can we just use fmod rather than doing things this way? It may well be
slower, but I don't care if that code is particularly fast; it doesn't run
all that often.
> I'm not sure I even want to fix this - my problem is that if the code
> has that kind of hideous assumption, what others are there in there
> waiting to bite?
Probably much less outside the floating point code; the floating point
code in there was marked preliminary and a hack when I originally picked
it up.
--
Russ Allbery (rra at stanford.edu) <http://www.eyrie.org/~eagle/>
Please send questions to the list rather than mailing me directly.
<http://www.eyrie.org/~eagle/faqs/questions.html> explains why.
More information about the inn-workers
mailing list