Commit 8019368c authored by Kai-Oliver Prott's avatar Kai-Oliver Prott
Browse files

Revert "Temporarily remove RealFrac"

This reverts commit 88e45e2f.
parent 88e45e2f
......@@ -25,7 +25,7 @@ module Prelude
-- ** Numerical Typeclasses
, Num (..), Fractional (..), Real (..)
, Integral (..), even, odd, fromIntegral, realToFrac, (^)
, Floating (..), Monoid (..)
, RealFrac (..), Floating (..), Monoid (..)
-- Type Constructor Classes
, Functor (..), Applicative (..), Alternative (..)
, Monad (..), MonadFail(..)
......@@ -947,6 +947,12 @@ class (Real a, Fractional a) => RealFrac a where
floor x = if r < 0 then n - 1 else n
where (n, r) = properFraction x
instance RealFrac Float where
properFraction x = (n, x - fromIntegral n)
where n = truncate x
truncate = fromInt . truncateFloat
round = fromInt . roundFloat
-- Conversion function from floating point numbers to integers.
-- The result is the closest integer between the argument and 0.
truncateFloat :: Float -> Int
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment