------------------------------------------------------------------------------
--                              Float 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.
properFractionFloatInt :: Float -> (Int, Float)
properFractionFloatInt (F# x) =
    if isTrue# (x `eqFloat#` 0.0#)
        then (I# 0#, F# 0.0#)
        else case float2Int# x of
                n -> (I# n, F# (x `minusFloat#` int2Float# n))

-- truncateFloatInt = float2Int

properFractionFloatInt :: Float -> (Int, Float)
properFractionFloatInt (F# x) =
    if isTrue# (x `eqFloat#` 0.0#)
        then (I# 0#, F# 0.0#)
        else case float2Int# x of
                n -> (I# n, F# (x `minusFloat#` int2Float# n))

-- truncateFloatInt = float2Int
properFractionFloatInt (F# x) =
    if isTrue# (x `eqFloat#` 0.0#)
        then (I# 0#, F# 0.0#)
        else case float2Int# x of
                n -> (I# n, F# (x `minusFloat#` int2Float# n))

-- truncateFloatInt = float2Int