#4344: Better toRational for Float and Double
----------------------------------------+-----------------------------------
Reporter: daniel.is.fischer | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 6.12.3
Keywords: toRational, performance | Testcase:
Blockedby: | Difficulty:
Os: Unknown/Multiple | Blocking:
Architecture: Unknown/Multiple | Failure: Runtime performance bug
----------------------------------------+-----------------------------------
Comment(by daniel.is.fischer):
Okay, how ugly are you willing to accept?
Counting zeros and shifting instead of calling out to `gcd` in the case of
negative exponent and even significand reduces the time needed for my
benchmarking loops by a factor of a bit above 2.
The code passed over 1.5 million !QuickCheck tests, so I'm pretty
confident I've got it right.
So far, I've used GHC.Integer.GMP.Internals (for the !ByteArray#), which
makes it not portable (and it doesn't work for `Int`s shorter than 32
bits).
But the significand is at most 53 bits, so I could use Int64 for the work
and stay portable. I'll try whether that is competitive. It would make the
code simpler, so it could even be faster.
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/4344#comment:3>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs