-----------------------------------------------------------------------------
--                              Double Methods                              --
------------------------------------------------------------------------------

-- Special Functions for Int, nice, easy and fast.
-- They should be small enough to be inlined automatically.

-- We have to test for ±0.0 to avoid returning -0.0 in the second
-- component of the pair. Unfortunately the branching costs a lot
-- of performance.
properFractionDoubleInt :: Double -> (Int, Double)
properFractionDoubleInt (D# x) =
    if isTrue# (x ==## 0.0##)
        then (I# 0#, D# 0.0##)
        else case double2Int# x of
                n -> (I# n, D# (x -## int2Double# n))

-- truncateDoubleInt = double2Int


properFractionDoubleInt :: Double -> (Int, Double)
properFractionDoubleInt (D# x) =
    if isTrue# (x ==## 0.0##)
        then (I# 0#, D# 0.0##)
        else case double2Int# x of
                n -> (I# n, D# (x -## int2Double# n))

-- truncateDoubleInt = double2Int
properFractionDoubleInt (D# x) =
    if isTrue# (x ==## 0.0##)
        then (I# 0#, D# 0.0##)
        else case double2Int# x of
                n -> (I# n, D# (x -## int2Double# n))

-- truncateDoubleInt = double2Int