
On 10/8/10 8:08 AM, Daniel Fischer wrote:
The methods of the RealFrac class produce garbage when the value lies outside the range of the target type, e.g.
Prelude GHC.Float> truncate 1.234e11 :: Int -- 32-bits -1154051584
and, in the case of truncate, different garbage when the rewrite rule fires:
Prelude GHC.Float> double2Int 1.234e11 -2147483648
I'm currently working on faster implementations of properFraction, truncate, round, ceiling and floor for Float and Double, so I'd like to know
- does it matter at all what garbage is returned in the above case?
I've never relied on particular garbage for these situations. Though I think it would be best if the firing of rewrite rules doesn't affect which garbage you get; that way bugs should be easier to locate since they're not dependent on optimization level, compiler version, etc. (Granted, consistent behavior may make *detecting* the presence of bugs a little harder.) -- Live well, ~wren