From 11a832d96a0109cdec05d8a23ff4a3d64959617b Mon Sep 17 00:00:00 2001 From: "ghc@cainnorris.net" Date: Mon, 16 Aug 2010 21:36:54 +0000 Subject: [PATCH] FIX #4228 (atanh (-1) returns NaN instead of -Infinity) --- Data/Complex.hs | 2 +- GHC/Float.lhs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Data/Complex.hs b/Data/Complex.hs index bbc8a07..6965547 100644 --- a/Data/Complex.hs +++ b/Data/Complex.hs @@ -198,4 +198,4 @@ instance (RealFloat a) => Floating (Complex a) where asinh z = log (z + sqrt (1+z*z)) acosh z = log (z + (z+1) * sqrt ((z-1)/(z+1))) - atanh z = log ((1+z) / sqrt (1-z*z)) + atanh z = 0.5 * log ((1.0+z) / (1.0-z)) diff --git a/GHC/Float.lhs b/GHC/Float.lhs index dbb556f..c31be1b 100644 --- a/GHC/Float.lhs +++ b/GHC/Float.lhs @@ -249,7 +249,7 @@ instance Floating Float where asinh x = log (x + sqrt (1.0+x*x)) acosh x = log (x + (x+1.0) * sqrt ((x-1.0)/(x+1.0))) - atanh x = log ((x+1.0) / sqrt (1.0-x*x)) + atanh x = 0.5 * log ((1.0+x) / (1.0-x)) instance RealFloat Float where floatRadix _ = FLT_RADIX -- from float.h @@ -331,7 +331,7 @@ instance Floating Double where asinh x = log (x + sqrt (1.0+x*x)) acosh x = log (x + (x+1.0) * sqrt ((x-1.0)/(x+1.0))) - atanh x = log ((x+1.0) / sqrt (1.0-x*x)) + atanh x = 0.5 * log ((1.0+x) / (1.0-x)) {-# RULES "truncate/Double->Int" truncate = double2Int #-} instance RealFrac Double where -- 1.7.10.4