From 27fc9462ece025be8f93a9f3b1e6e5da2b1bbced Mon Sep 17 00:00:00 2001 From: Nick Bowler Date: Wed, 27 Jan 2010 08:55:07 -0500 Subject: [PATCH] floating: Add nearbyint to the RealFloat class. This is meaningful now that we have support for changing the rounding mode. --- Data/Floating/Classes.hs | 1 + Data/Floating/Double.hs | 1 + Data/Floating/Environment.hs | 1 + Data/Floating/Float.hs | 1 + 4 files changed, 4 insertions(+) diff --git a/Data/Floating/Classes.hs b/Data/Floating/Classes.hs index 717a218..51f46ff 100644 --- a/Data/Floating/Classes.hs +++ b/Data/Floating/Classes.hs @@ -88,6 +88,7 @@ class Floating a => RealFloat a where erfc :: a -> a lgamma :: a -> a tgamma :: a -> a + nearbyint :: a -> a classify :: a -> FPClassification infinity :: a nan :: a diff --git a/Data/Floating/Double.hs b/Data/Floating/Double.hs index 54e32a2..196786c 100644 --- a/Data/Floating/Double.hs +++ b/Data/Floating/Double.hs @@ -154,6 +154,7 @@ instance RealFloat Double where erfc = libmDouble c_erfc lgamma = libmDouble c_lgamma tgamma = libmDouble c_tgamma + nearbyint = libmDouble c_nearbyint classify = toEnum . fromIntegral . double_classify . toFloating fquotRem x y = unsafePerformIO . alloca $ \quotPtr -> do diff --git a/Data/Floating/Environment.hs b/Data/Floating/Environment.hs index de67cb7..dd103b5 100644 --- a/Data/Floating/Environment.hs +++ b/Data/Floating/Environment.hs @@ -134,6 +134,7 @@ instance RealFloat a => RealFloat (FEnv a) where erfc = liftA erfc lgamma = liftA lgamma tgamma = liftA tgamma + nearbyint = liftA nearbyint classify = error "classify is not supported on FEnv." fquotRem = error "fquotRem is not supported on FEnv." diff --git a/Data/Floating/Float.hs b/Data/Floating/Float.hs index 1fa3ec0..6a1af1f 100644 --- a/Data/Floating/Float.hs +++ b/Data/Floating/Float.hs @@ -150,6 +150,7 @@ instance RealFloat Float where erfc = libmFloat c_erfcf lgamma = libmFloat c_lgammaf tgamma = libmFloat c_tgammaf + nearbyint = libmFloat c_nearbyintf classify = toEnum . fromIntegral . float_classify . toFloating fquotRem x y = unsafePerformIO . alloca $ \quotPtr -> do -- 2.11.4.GIT