[commit: base] master: Add fromIntegral/Word->Double and fromIntegral/Word-Float rules (7ed0451)
Johan Tibell
johan.tibell at gmail.com
Fri Dec 14 01:03:12 CET 2012
Repository : ssh://darcs.haskell.org//srv/darcs/packages/base
On branch : master
http://hackage.haskell.org/trac/ghc/changeset/7ed045164892688bc9823c709787307f2fff312c
>---------------------------------------------------------------
commit 7ed045164892688bc9823c709787307f2fff312c
Author: Johan Tibell <johan.tibell at gmail.com>
Date: Thu Dec 13 14:49:58 2012 -0800
Add fromIntegral/Word->Double and fromIntegral/Word-Float rules
>---------------------------------------------------------------
GHC/Float.lhs | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/GHC/Float.lhs b/GHC/Float.lhs
index 66318d4..59b7542 100644
--- a/GHC/Float.lhs
+++ b/GHC/Float.lhs
@@ -1110,9 +1110,18 @@ foreign import ccall unsafe "isDoubleFinite" isDoubleFinite :: Double -> Int
%*********************************************************
\begin{code}
+
+word2Double :: Word -> Double
+word2Double (W# w) = D# (word2Double# w)
+
+word2Float :: Word -> Float
+word2Float (W# w) = F# (word2Float# w)
+
{-# RULES
"fromIntegral/Int->Float" fromIntegral = int2Float
"fromIntegral/Int->Double" fromIntegral = int2Double
+"fromIntegral/Word->Float" fromIntegral = word2Float
+"fromIntegral/Word->Double" fromIntegral = word2Double
"realToFrac/Float->Float" realToFrac = id :: Float -> Float
"realToFrac/Float->Double" realToFrac = float2Double
"realToFrac/Double->Float" realToFrac = double2Float
More information about the Cvs-libraries
mailing list