Re: rational to floating point?

Thant Tessman <thant@acm.org>
14 Oct 2003 23:51:38 -0400

          From comp.compilers

Related articles
rational to floating point? thant@acm.org (Thant Tessman) (2003-10-13)
Re: rational to floating point? mitr@volny.cz (Miloslav Trmac) (2003-10-13)
Re: rational to floating point? nmm1@cus.cam.ac.uk (2003-10-13)
Re: rational to floating point? haberg@matematik.su.se (2003-10-13)
Re: rational to floating point? thant@acm.org (Thant Tessman) (2003-10-14)
Re: rational to floating point? fjh@cs.mu.oz.au (Fergus Henderson) (2003-10-18)
Re: rational to floating point? nmm1@cus.cam.ac.uk (2003-10-18)
Re: rational to floating point? Peter-Lawrence.Montgomery@cwi.nl (2003-10-18)
Re: rational to floating point? thant@acm.org (Thant Tessman) (2003-10-27)
| List of all articles for this month |
From: Thant Tessman <thant@acm.org>
Newsgroups: comp.compilers
Date: 14 Oct 2003 23:51:38 -0400
Organization: XMission http://www.xmission.com/
References: 03-10-065
Keywords: arithmetic, summary
Posted-Date: 14 Oct 2003 23:51:38 EDT

I asked:


> Can anyone recommend a source of information on converting
> arbitrary-precision rationals to floating-point numbers? [...]


Thank you for all the replies. Here is a summation of good sources:


"How to Read Floating Point Numbers Accurately," William D Clinger
Canonical Knuth, Volume 2 "The Art of Computer Programming:
Seminumerical Algorithms"
"What Every Computer Scientist Should Know About Floating-Point
Arithmetic," David Goldberg
and the GNU GMP looks like a good place to try to find an example
implementation.


I haven't had time to give the above the full attention they deserve,
but I think I have a handle on how to produce the significand and
exponent of the floating point number (as arbitrary-precision integers
(conveniently in base 256 in my implementation)). What's missing is
the conversion to the actual float. The Clinger paper makes use of a
mysteriously unexplained "make-float" function, for which there seems
to be no portable manifestation. Things like radix conversion are no
sweat, but bit twiddling is not something I've had a lot of experience
with. Is it typical in these situations to produce the IEEE 754 float
bit pattern directly? If so, do I have to worry not only about whether
that's the standard on the chosen platform, but also about things like
endianness?


-thant
[Yes, one typically twiddles the bits directly, and you have to be aware
of endianness. Fortunately, these days the only popular formats are
big- and little-endian IEEE and maybe legacy IBM hex. -John]



Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.