
15 Jan
2008
15 Jan
'08
1:40 a.m.
On Mon, 14 Jan 2008, John Meacham wrote:
On Sun, Jan 13, 2008 at 01:08:49AM +0100, Henning Thielemann wrote:
Is there a fast and reliable way to compute the fraction of a floating point number?
no, and this has bothered me to the point I consider it a bug in the language spec that all 'rounding' style functions give back an integral type.
I find returning an Integral is appropriate. The type expresses perfectly what kind of values you can expect. Sure, there should be some optimization rule like fromInteger (round x) = roundf x . However, the 'fraction' function gets a fraction and returns a fraction and doesn't care about the type of the integer part. As I see this is also missing from your RealFrac class extension.