blob: c636ae5ea30cfd0a195a08cd9de373d0975507b4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
{-# LANGUAGE MagicHash , UnboxedTuples #-}
module T8598(fun) where
import GHC.Float (Double(..))
import GHC.Num.Integer (integerDecodeDouble#, integerEncodeDouble#)
-- Float.scaleFloat for Doubles, slightly simplified
fun :: Double -> Double
fun x | isFix = x
| otherwise = case x of
(D# x#) -> case integerDecodeDouble# x# of
(# i, j #) -> D# (integerEncodeDouble# i j)
where
isFix = isDoubleFinite x == 0
foreign import ccall unsafe "isDoubleFinite" isDoubleFinite :: Double -> Int
|