Unsigned -> float conversion

Wendy Thrash wendyt at pyramid.UUCP
Tue Apr 8 08:45:07 AEST 1986


In article <144 at daisy.warwick.UUCP> cudcv at daisy.warwk.ac.uk (Rob McMahon) writes
>Pointed out to me by someone here - what does your favourite C compiler make
>of this program :
>[program involving conversion of large unsigned to float/double]

A few months ago I posted a similar (but much larger) program to net.lang.c.
(My address at that time was ...pyramid!isieng!wendyt, for you greppers.)
Several people posted followups, others sent me mail, and I eventually
summarized to the net.  If you're interested in this problem you might want
to check your news archives, but to summarize briefly, Vaxen running System V
tend to do things right; just about everyone else messes up something (including
the compiler I was working on at the time).

This problem arises because hardware usually provides instructions to convert
float/double to/from int, but never seems to provide instructions for unsigned
conversion.  Doing the unsigned conversions correctly is a real pain in the
bazooka for a compiler writer, so s/he tends to take an "Oh well, who'd want
to do this anyway?" approach.  This is, of course, very bad form.

But say, folks, when you see something like this on the net and find it
to produce bizarre results on your hardware, please send a note off to the
manufacturer!  Believe it or not, not all hardware makers read the news;
perhaps some who don't still read their bug reports.



More information about the Comp.unix.wizards mailing list