fp-ieee 0.1.0.5 → 0.1.0.6
raw patch · 12 files changed
+205/−188 lines, 12 filesdep ~QuickCheckdep ~basedep ~doctestPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: QuickCheck, base, doctest, random, tasty-bench
API changes (from Hackage documentation)
Files
- fp-ieee.cabal +34/−9
- src/Numeric/Floating/IEEE/Internal/Augmented.hs +4/−2
- src/Numeric/Floating/IEEE/Internal/Base.hs +6/−3
- src/Numeric/Floating/IEEE/Internal/Conversion.hs +2/−1
- src/Numeric/Floating/IEEE/Internal/FMA.hs +6/−3
- src/Numeric/Floating/IEEE/Internal/Float128.hs +27/−32
- src/Numeric/Floating/IEEE/Internal/Half.hs +35/−40
- src/Numeric/Floating/IEEE/Internal/Rounding/Encode.hs +34/−38
- src/Numeric/Floating/IEEE/Internal/Rounding/Integral.hs +34/−38
- src/Numeric/Floating/IEEE/Internal/Rounding/Rational.hs +17/−19
- test/ClassificationSpec.hs +4/−2
- test/NaNSpec.hs +2/−1
fp-ieee.cabal view
@@ -1,7 +1,7 @@ cabal-version: 2.2 name: fp-ieee-version: 0.1.0.5+version: 0.1.0.6 synopsis: IEEE 754-2019 compliant operations description: Please see the README on GitHub at <https://github.com/minoki/haskell-floating-point/tree/master/fp-ieee#readme> category: Numeric, Math@@ -9,7 +9,7 @@ bug-reports: https://github.com/minoki/haskell-floating-point/issues author: ARATA Mizuki maintainer: minorinoki@gmail.com-copyright: 2020-2024 ARATA Mizuki+copyright: 2020-2025 ARATA Mizuki license: BSD-3-Clause license-file: LICENSE build-type: Simple@@ -72,7 +72,7 @@ -- We use a post-GHC 8.6 language extension: NumericUnderscores -- cast{Word32,Word64}To{Float,Double}, cast{Float,Double}To{Word32,Word64} are since base-4.10.0.0 (GHC 8.2) -- Semigroup((<>)) is exported from Prelude since base-4.11.0.0 (GHC 8.4)- base >=4.12 && <4.22+ base >=4.12 && <4.23 if !flag(pure-hs) cpp-options: -DUSE_FFI if !flag(pure-hs) && os(windows)@@ -132,6 +132,17 @@ build-depends: integer-logarithms >=1 && <1.1 ghc-options: -Wall+ other-extensions:+ BangPatterns+ CPP+ DeriveFunctor+ MagicHash+ NoImplicitPrelude+ NumericUnderscores+ ScopedTypeVariables+ TypeApplications+ UnboxedSums+ UnboxedTuples if flag(half) other-modules: Numeric.Floating.IEEE.Internal.Half@@ -203,10 +214,10 @@ type: exitcode-stdio-1.0 main-is: doctests.hs build-depends:- doctest ^>=0.22.2- , QuickCheck >=2.14.3 && <2.16+ doctest >=0.22.2 && <0.25+ , QuickCheck >=2.14.3 && <2.18 default-language: Haskell2010- if impl(ghc >= 9.12)+ if impl(ghc >= 9.14) buildable: False test-suite fp-ieee-test@@ -229,12 +240,21 @@ test ghc-options: -threaded -rtsopts -with-rtsopts=-N -fno-ignore-asserts build-depends:- QuickCheck >=2.14.3 && <2.16+ QuickCheck >=2.14.3 && <2.18 , fp-ieee , hspec ^>=2.11.7 , hspec-core ^>=2.11.7 , integer-logarithms- , random ^>=1.2.1.1+ , random >=1.2.1.1 && <1.4+ other-extensions:+ BangPatterns+ CPP+ DeriveFunctor+ GeneralizedNewtypeDeriving+ HexFloatLiterals+ NumericUnderscores+ RankNTypes+ ScopedTypeVariables if flag(half) other-modules: HalfSpec@@ -251,5 +271,10 @@ benchmark build-depends: fp-ieee- , tasty-bench ^>=0.3.5+ , tasty-bench >=0.3.5 && <0.6+ other-extensions:+ BangPatterns+ CPP+ HexFloatLiterals+ NumericUnderscores default-language: Haskell2010
src/Numeric/Floating/IEEE/Internal/Augmented.hs view
@@ -71,7 +71,8 @@ (r1, r1) -- unavoidable overflow else assert (r2 /= 0) (r1, r2)-{-# SPECIALIZE augmentedAddition :: Float -> Float -> (Float, Float), Double -> Double -> (Double, Double) #-}+{-# SPECIALIZE augmentedAddition :: Float -> Float -> (Float, Float) #-}+{-# SPECIALIZE augmentedAddition :: Double -> Double -> (Double, Double) #-} -- | -- IEEE 754 @augmentedSubtraction@ operation.@@ -162,4 +163,5 @@ z' else w'-{-# SPECIALIZE augmentedMultiplication :: Float -> Float -> (Float, Float), Double -> Double -> (Double, Double) #-}+{-# SPECIALIZE augmentedMultiplication :: Float -> Float -> (Float, Float) #-}+{-# SPECIALIZE augmentedMultiplication :: Double -> Double -> (Double, Double) #-}
src/Numeric/Floating/IEEE/Internal/Base.hs view
@@ -53,7 +53,8 @@ x = encodeFloat 1 (expMin - d) in x {-# INLINABLE minPositive #-}-{-# SPECIALIZE minPositive :: Float, Double #-}+{-# SPECIALIZE minPositive :: Float #-}+{-# SPECIALIZE minPositive :: Double #-} -- | -- The smallest positive normal value expressible in an IEEE floating-point format.@@ -75,7 +76,8 @@ x = encodeFloat 1 (expMin - 1) in x {-# INLINABLE minPositiveNormal #-}-{-# SPECIALIZE minPositiveNormal :: Float, Double #-}+{-# SPECIALIZE minPositiveNormal :: Float #-}+{-# SPECIALIZE minPositiveNormal :: Double #-} -- | -- The largest finite value expressible in an IEEE floating-point format.@@ -91,7 +93,8 @@ x = encodeFloat (r ^! d - 1) (expMax - d) in x {-# INLINABLE maxFinite #-}-{-# SPECIALIZE maxFinite :: Float, Double #-}+{-# SPECIALIZE maxFinite :: Float #-}+{-# SPECIALIZE maxFinite :: Double #-} -- A variant of (^) that allows constant folding infixr 8 ^!
src/Numeric/Floating/IEEE/Internal/Conversion.hs view
@@ -57,7 +57,8 @@ #else -{-# SPECIALIZE canonicalize :: Float -> Float, Double -> Double #-}+{-# SPECIALIZE canonicalize :: Float -> Float #-}+{-# SPECIALIZE canonicalize :: Double -> Double #-} canonicalizeFloat :: Float -> Float canonicalizeFloat = canonicalize
src/Numeric/Floating/IEEE/Internal/FMA.hs view
@@ -83,7 +83,8 @@ a - (x - b) -} in (x, y)-{-# SPECIALIZE twoSum :: Float -> Float -> (Float, Float), Double -> Double -> (Double, Double) #-}+{-# SPECIALIZE twoSum :: Float -> Float -> (Float, Float) #-}+{-# SPECIALIZE twoSum :: Double -> Double -> (Double, Double) #-} -- | -- Addition, with round to nearest odd floating-point number.@@ -106,7 +107,8 @@ | otherwise = u !_ = assert (isInfinite u || toRational u == toRational x + toRational y || not (isMantissaEven result)) () in result-{-# SPECIALIZE addToOdd :: Float -> Float -> Float, Double -> Double -> Double #-}+{-# SPECIALIZE addToOdd :: Float -> Float -> Float #-}+{-# SPECIALIZE addToOdd :: Double -> Double -> Double #-} -- This function doesn't handle overflow or underflow split :: RealFloat a => a -> (a, a)@@ -117,7 +119,8 @@ in (x, y) where factor = fromInteger $ 1 + floatRadix a ^! ((floatDigits a + 1) `quot` 2) -- factor == 134217729 for Double, 4097 for Float-{-# SPECIALIZE split :: Float -> (Float, Float), Double -> (Double, Double) #-}+{-# SPECIALIZE split :: Float -> (Float, Float) #-}+{-# SPECIALIZE split :: Double -> (Double, Double) #-} -- This function will be rewritten into fastTwoProduct{Float,Double} if fast FMA is available; the rewriting may change behavior regarding overflow. -- TODO: subnormal behavior?
src/Numeric/Floating/IEEE/Internal/Float128.hs view
@@ -198,35 +198,30 @@ {-# SPECIALIZE maxFinite :: Float128 #-} -- We shouldn't need specializations of positiveWordToBinaryFloatR# as long as WORD_SIZE_IN_BITS <= 113-{-# SPECIALIZE- fromPositiveIntegerR :: RoundingStrategy f => Bool -> Integer -> f Float128- , Bool -> Integer -> RoundTiesToEven Float128- , Bool -> Integer -> RoundTiesToAway Float128- , Bool -> Integer -> RoundTowardPositive Float128- , Bool -> Integer -> RoundTowardNegative Float128- , Bool -> Integer -> RoundTowardZero Float128- #-}-{-# SPECIALIZE- fromPositiveRatioR :: RoundingStrategy f => Bool -> Integer -> Integer -> f Float128- , Bool -> Integer -> Integer -> RoundTiesToEven Float128- , Bool -> Integer -> Integer -> RoundTiesToAway Float128- , Bool -> Integer -> Integer -> RoundTowardPositive Float128- , Bool -> Integer -> Integer -> RoundTowardNegative Float128- , Bool -> Integer -> Integer -> RoundTowardZero Float128- #-}-{-# SPECIALIZE- encodePositiveFloatR# :: RoundingStrategy f => Bool -> Integer -> Int# -> f Float128- , Bool -> Integer -> Int# -> RoundTiesToEven Float128- , Bool -> Integer -> Int# -> RoundTiesToAway Float128- , Bool -> Integer -> Int# -> RoundTowardPositive Float128- , Bool -> Integer -> Int# -> RoundTowardNegative Float128- , Bool -> Integer -> Int# -> RoundTowardZero Float128- #-}-{-# SPECIALIZE- scaleFloatR# :: RoundingStrategy f => Int# -> Float128 -> f Float128- , Int# -> Float128 -> RoundTiesToEven Float128- , Int# -> Float128 -> RoundTiesToAway Float128- , Int# -> Float128 -> RoundTowardPositive Float128- , Int# -> Float128 -> RoundTowardNegative Float128- , Int# -> Float128 -> RoundTowardZero Float128- #-}+{-# SPECIALIZE fromPositiveIntegerR :: RoundingStrategy f => Bool -> Integer -> f Float128 #-}+{-# SPECIALIZE fromPositiveIntegerR :: Bool -> Integer -> RoundTiesToEven Float128 #-}+{-# SPECIALIZE fromPositiveIntegerR :: Bool -> Integer -> RoundTiesToAway Float128 #-}+{-# SPECIALIZE fromPositiveIntegerR :: Bool -> Integer -> RoundTowardPositive Float128 #-}+{-# SPECIALIZE fromPositiveIntegerR :: Bool -> Integer -> RoundTowardNegative Float128 #-}+{-# SPECIALIZE fromPositiveIntegerR :: Bool -> Integer -> RoundTowardZero Float128 #-}++{-# SPECIALIZE fromPositiveRatioR :: RoundingStrategy f => Bool -> Integer -> Integer -> f Float128 #-}+{-# SPECIALIZE fromPositiveRatioR :: Bool -> Integer -> Integer -> RoundTiesToEven Float128 #-}+{-# SPECIALIZE fromPositiveRatioR :: Bool -> Integer -> Integer -> RoundTiesToAway Float128 #-}+{-# SPECIALIZE fromPositiveRatioR :: Bool -> Integer -> Integer -> RoundTowardPositive Float128 #-}+{-# SPECIALIZE fromPositiveRatioR :: Bool -> Integer -> Integer -> RoundTowardNegative Float128 #-}+{-# SPECIALIZE fromPositiveRatioR :: Bool -> Integer -> Integer -> RoundTowardZero Float128 #-}++{-# SPECIALIZE encodePositiveFloatR# :: RoundingStrategy f => Bool -> Integer -> Int# -> f Float128 #-}+{-# SPECIALIZE encodePositiveFloatR# :: Bool -> Integer -> Int# -> RoundTiesToEven Float128 #-}+{-# SPECIALIZE encodePositiveFloatR# :: Bool -> Integer -> Int# -> RoundTiesToAway Float128 #-}+{-# SPECIALIZE encodePositiveFloatR# :: Bool -> Integer -> Int# -> RoundTowardPositive Float128 #-}+{-# SPECIALIZE encodePositiveFloatR# :: Bool -> Integer -> Int# -> RoundTowardNegative Float128 #-}+{-# SPECIALIZE encodePositiveFloatR# :: Bool -> Integer -> Int# -> RoundTowardZero Float128 #-}++{-# SPECIALIZE scaleFloatR# :: RoundingStrategy f => Int# -> Float128 -> f Float128 #-}+{-# SPECIALIZE scaleFloatR# :: Int# -> Float128 -> RoundTiesToEven Float128 #-}+{-# SPECIALIZE scaleFloatR# :: Int# -> Float128 -> RoundTiesToAway Float128 #-}+{-# SPECIALIZE scaleFloatR# :: Int# -> Float128 -> RoundTowardPositive Float128 #-}+{-# SPECIALIZE scaleFloatR# :: Int# -> Float128 -> RoundTowardNegative Float128 #-}+{-# SPECIALIZE scaleFloatR# :: Int# -> Float128 -> RoundTowardZero Float128 #-}
src/Numeric/Floating/IEEE/Internal/Half.hs view
@@ -154,46 +154,41 @@ {-# SPECIALIZE minPositive :: Half #-} {-# SPECIALIZE minPositiveNormal :: Half #-} {-# SPECIALIZE maxFinite :: Half #-}-{-# SPECIALIZE- positiveWordToBinaryFloatR# :: RoundingStrategy f => Bool -> Word# -> f Half- , Bool -> Word# -> RoundTiesToEven Half- , Bool -> Word# -> RoundTiesToAway Half- , Bool -> Word# -> RoundTowardPositive Half- , Bool -> Word# -> RoundTowardNegative Half- , Bool -> Word# -> RoundTowardZero Half- #-}-{-# SPECIALIZE- fromPositiveIntegerR :: RoundingStrategy f => Bool -> Integer -> f Half- , Bool -> Integer -> RoundTiesToEven Half- , Bool -> Integer -> RoundTiesToAway Half- , Bool -> Integer -> RoundTowardPositive Half- , Bool -> Integer -> RoundTowardNegative Half- , Bool -> Integer -> RoundTowardZero Half- #-}-{-# SPECIALIZE- fromPositiveRatioR :: RoundingStrategy f => Bool -> Integer -> Integer -> f Half- , Bool -> Integer -> Integer -> RoundTiesToEven Half- , Bool -> Integer -> Integer -> RoundTiesToAway Half- , Bool -> Integer -> Integer -> RoundTowardPositive Half- , Bool -> Integer -> Integer -> RoundTowardNegative Half- , Bool -> Integer -> Integer -> RoundTowardZero Half- #-}-{-# SPECIALIZE- encodePositiveFloatR# :: RoundingStrategy f => Bool -> Integer -> Int# -> f Half- , Bool -> Integer -> Int# -> RoundTiesToEven Half- , Bool -> Integer -> Int# -> RoundTiesToAway Half- , Bool -> Integer -> Int# -> RoundTowardPositive Half- , Bool -> Integer -> Int# -> RoundTowardNegative Half- , Bool -> Integer -> Int# -> RoundTowardZero Half- #-}-{-# SPECIALIZE- scaleFloatR# :: RoundingStrategy f => Int# -> Half -> f Half- , Int# -> Half -> RoundTiesToEven Half- , Int# -> Half -> RoundTiesToAway Half- , Int# -> Half -> RoundTowardPositive Half- , Int# -> Half -> RoundTowardNegative Half- , Int# -> Half -> RoundTowardZero Half- #-}++{-# SPECIALIZE positiveWordToBinaryFloatR# :: RoundingStrategy f => Bool -> Word# -> f Half #-}+{-# SPECIALIZE positiveWordToBinaryFloatR# :: Bool -> Word# -> RoundTiesToEven Half #-}+{-# SPECIALIZE positiveWordToBinaryFloatR# :: Bool -> Word# -> RoundTiesToAway Half #-}+{-# SPECIALIZE positiveWordToBinaryFloatR# :: Bool -> Word# -> RoundTowardPositive Half #-}+{-# SPECIALIZE positiveWordToBinaryFloatR# :: Bool -> Word# -> RoundTowardNegative Half #-}+{-# SPECIALIZE positiveWordToBinaryFloatR# :: Bool -> Word# -> RoundTowardZero Half #-}++{-# SPECIALIZE fromPositiveIntegerR :: RoundingStrategy f => Bool -> Integer -> f Half #-}+{-# SPECIALIZE fromPositiveIntegerR :: Bool -> Integer -> RoundTiesToEven Half #-}+{-# SPECIALIZE fromPositiveIntegerR :: Bool -> Integer -> RoundTiesToAway Half #-}+{-# SPECIALIZE fromPositiveIntegerR :: Bool -> Integer -> RoundTowardPositive Half #-}+{-# SPECIALIZE fromPositiveIntegerR :: Bool -> Integer -> RoundTowardNegative Half #-}+{-# SPECIALIZE fromPositiveIntegerR :: Bool -> Integer -> RoundTowardZero Half #-}++{-# SPECIALIZE fromPositiveRatioR :: RoundingStrategy f => Bool -> Integer -> Integer -> f Half #-}+{-# SPECIALIZE fromPositiveRatioR :: Bool -> Integer -> Integer -> RoundTiesToEven Half #-}+{-# SPECIALIZE fromPositiveRatioR :: Bool -> Integer -> Integer -> RoundTiesToAway Half #-}+{-# SPECIALIZE fromPositiveRatioR :: Bool -> Integer -> Integer -> RoundTowardPositive Half #-}+{-# SPECIALIZE fromPositiveRatioR :: Bool -> Integer -> Integer -> RoundTowardNegative Half #-}+{-# SPECIALIZE fromPositiveRatioR :: Bool -> Integer -> Integer -> RoundTowardZero Half #-}++{-# SPECIALIZE encodePositiveFloatR# :: RoundingStrategy f => Bool -> Integer -> Int# -> f Half #-}+{-# SPECIALIZE encodePositiveFloatR# :: Bool -> Integer -> Int# -> RoundTiesToEven Half #-}+{-# SPECIALIZE encodePositiveFloatR# :: Bool -> Integer -> Int# -> RoundTiesToAway Half #-}+{-# SPECIALIZE encodePositiveFloatR# :: Bool -> Integer -> Int# -> RoundTowardPositive Half #-}+{-# SPECIALIZE encodePositiveFloatR# :: Bool -> Integer -> Int# -> RoundTowardNegative Half #-}+{-# SPECIALIZE encodePositiveFloatR# :: Bool -> Integer -> Int# -> RoundTowardZero Half #-}++{-# SPECIALIZE scaleFloatR# :: RoundingStrategy f => Int# -> Half -> f Half #-}+{-# SPECIALIZE scaleFloatR# :: Int# -> Half -> RoundTiesToEven Half #-}+{-# SPECIALIZE scaleFloatR# :: Int# -> Half -> RoundTiesToAway Half #-}+{-# SPECIALIZE scaleFloatR# :: Int# -> Half -> RoundTowardPositive Half #-}+{-# SPECIALIZE scaleFloatR# :: Int# -> Half -> RoundTowardNegative Half #-}+{-# SPECIALIZE scaleFloatR# :: Int# -> Half -> RoundTowardZero Half #-} -- Monomorphic conversion functions halfToFloat :: Half -> Float
src/Numeric/Floating/IEEE/Internal/Rounding/Encode.hs view
@@ -105,25 +105,23 @@ !fDigits = floatDigits (undefined :: a) -- 53 for Double (!expMin, !expMax) = floatRange (undefined :: a) -- (-1021, 1024) for Double {-# INLINABLE [0] encodePositiveFloatR# #-}-{-# SPECIALIZE- encodePositiveFloatR# :: RealFloat a => Bool -> Integer -> Int# -> RoundTiesToEven a- , RealFloat a => Bool -> Integer -> Int# -> RoundTiesToAway a- , RealFloat a => Bool -> Integer -> Int# -> RoundTowardPositive a- , RealFloat a => Bool -> Integer -> Int# -> RoundTowardZero a- , RealFloat a => Bool -> Integer -> Int# -> Product RoundTowardNegative RoundTowardPositive a- , RoundingStrategy f => Bool -> Integer -> Int# -> f Double- , RoundingStrategy f => Bool -> Integer -> Int# -> f Float- , Bool -> Integer -> Int# -> RoundTiesToEven Double- , Bool -> Integer -> Int# -> RoundTiesToAway Double- , Bool -> Integer -> Int# -> RoundTowardPositive Double- , Bool -> Integer -> Int# -> RoundTowardZero Double- , Bool -> Integer -> Int# -> RoundTiesToEven Float- , Bool -> Integer -> Int# -> RoundTiesToAway Float- , Bool -> Integer -> Int# -> RoundTowardPositive Float- , Bool -> Integer -> Int# -> RoundTowardZero Float- , Bool -> Integer -> Int# -> Product RoundTowardNegative RoundTowardPositive Double- , Bool -> Integer -> Int# -> Product RoundTowardNegative RoundTowardPositive Float- #-}+{-# SPECIALIZE encodePositiveFloatR# :: RealFloat a => Bool -> Integer -> Int# -> RoundTiesToEven a #-}+{-# SPECIALIZE encodePositiveFloatR# :: RealFloat a => Bool -> Integer -> Int# -> RoundTiesToAway a #-}+{-# SPECIALIZE encodePositiveFloatR# :: RealFloat a => Bool -> Integer -> Int# -> RoundTowardPositive a #-}+{-# SPECIALIZE encodePositiveFloatR# :: RealFloat a => Bool -> Integer -> Int# -> RoundTowardZero a #-}+{-# SPECIALIZE encodePositiveFloatR# :: RealFloat a => Bool -> Integer -> Int# -> Product RoundTowardNegative RoundTowardPositive a #-}+{-# SPECIALIZE encodePositiveFloatR# :: RoundingStrategy f => Bool -> Integer -> Int# -> f Double #-}+{-# SPECIALIZE encodePositiveFloatR# :: RoundingStrategy f => Bool -> Integer -> Int# -> f Float #-}+{-# SPECIALIZE encodePositiveFloatR# :: Bool -> Integer -> Int# -> RoundTiesToEven Double #-}+{-# SPECIALIZE encodePositiveFloatR# :: Bool -> Integer -> Int# -> RoundTiesToAway Double #-}+{-# SPECIALIZE encodePositiveFloatR# :: Bool -> Integer -> Int# -> RoundTowardPositive Double #-}+{-# SPECIALIZE encodePositiveFloatR# :: Bool -> Integer -> Int# -> RoundTowardZero Double #-}+{-# SPECIALIZE encodePositiveFloatR# :: Bool -> Integer -> Int# -> RoundTiesToEven Float #-}+{-# SPECIALIZE encodePositiveFloatR# :: Bool -> Integer -> Int# -> RoundTiesToAway Float #-}+{-# SPECIALIZE encodePositiveFloatR# :: Bool -> Integer -> Int# -> RoundTowardPositive Float #-}+{-# SPECIALIZE encodePositiveFloatR# :: Bool -> Integer -> Int# -> RoundTowardZero Float #-}+{-# SPECIALIZE encodePositiveFloatR# :: Bool -> Integer -> Int# -> Product RoundTowardNegative RoundTowardPositive Double #-}+{-# SPECIALIZE encodePositiveFloatR# :: Bool -> Integer -> Int# -> Product RoundTowardNegative RoundTowardPositive Float #-} {-# RULES "encodePositiveFloatR#/RoundTowardNegative" encodePositiveFloatR# = \neg x y -> RoundTowardNegative (roundTowardPositive (encodePositiveFloatR# (not neg) x y))@@ -183,22 +181,20 @@ (expMin,expMax) = floatRange x fDigits = floatDigits x {-# INLINABLE [0] scaleFloatR# #-}-{-# SPECIALIZE- scaleFloatR# :: RealFloat a => Int# -> a -> RoundTiesToEven a- , RealFloat a => Int# -> a -> RoundTiesToAway a- , RealFloat a => Int# -> a -> RoundTowardPositive a- , RealFloat a => Int# -> a -> RoundTowardNegative a- , RealFloat a => Int# -> a -> RoundTowardZero a- , RoundingStrategy f => Int# -> Double -> f Double- , RoundingStrategy f => Int# -> Float -> f Float- , Int# -> Double -> RoundTiesToEven Double- , Int# -> Double -> RoundTiesToAway Double- , Int# -> Double -> RoundTowardPositive Double- , Int# -> Double -> RoundTowardNegative Double- , Int# -> Double -> RoundTowardZero Double- , Int# -> Float -> RoundTiesToEven Float- , Int# -> Float -> RoundTiesToAway Float- , Int# -> Float -> RoundTowardPositive Float- , Int# -> Float -> RoundTowardNegative Float- , Int# -> Float -> RoundTowardZero Float- #-}+{-# SPECIALIZE scaleFloatR# :: RealFloat a => Int# -> a -> RoundTiesToEven a #-}+{-# SPECIALIZE scaleFloatR# :: RealFloat a => Int# -> a -> RoundTiesToAway a #-}+{-# SPECIALIZE scaleFloatR# :: RealFloat a => Int# -> a -> RoundTowardPositive a #-}+{-# SPECIALIZE scaleFloatR# :: RealFloat a => Int# -> a -> RoundTowardNegative a #-}+{-# SPECIALIZE scaleFloatR# :: RealFloat a => Int# -> a -> RoundTowardZero a #-}+{-# SPECIALIZE scaleFloatR# :: RoundingStrategy f => Int# -> Double -> f Double #-}+{-# SPECIALIZE scaleFloatR# :: RoundingStrategy f => Int# -> Float -> f Float #-}+{-# SPECIALIZE scaleFloatR# :: Int# -> Double -> RoundTiesToEven Double #-}+{-# SPECIALIZE scaleFloatR# :: Int# -> Double -> RoundTiesToAway Double #-}+{-# SPECIALIZE scaleFloatR# :: Int# -> Double -> RoundTowardPositive Double #-}+{-# SPECIALIZE scaleFloatR# :: Int# -> Double -> RoundTowardNegative Double #-}+{-# SPECIALIZE scaleFloatR# :: Int# -> Double -> RoundTowardZero Double #-}+{-# SPECIALIZE scaleFloatR# :: Int# -> Float -> RoundTiesToEven Float #-}+{-# SPECIALIZE scaleFloatR# :: Int# -> Float -> RoundTiesToAway Float #-}+{-# SPECIALIZE scaleFloatR# :: Int# -> Float -> RoundTowardPositive Float #-}+{-# SPECIALIZE scaleFloatR# :: Int# -> Float -> RoundTowardNegative Float #-}+{-# SPECIALIZE scaleFloatR# :: Int# -> Float -> RoundTowardZero Float #-}
src/Numeric/Floating/IEEE/Internal/Rounding/Integral.hs view
@@ -228,25 +228,23 @@ !fDigits = floatDigits (undefined :: a) -- 53 for Double (_expMin, !expMax) = floatRange (undefined :: a) -- (-1021, 1024) for Double {-# INLINABLE [0] positiveWordToBinaryFloatR# #-}-{-# SPECIALIZE- positiveWordToBinaryFloatR# :: RoundingStrategy f => Bool -> Word# -> f Float- , RoundingStrategy f => Bool -> Word# -> f Double- , RealFloat a => Bool -> Word# -> RoundTiesToEven a- , RealFloat a => Bool -> Word# -> RoundTiesToAway a- , RealFloat a => Bool -> Word# -> RoundTowardPositive a- , RealFloat a => Bool -> Word# -> RoundTowardZero a- , RealFloat a => Bool -> Word# -> Product RoundTowardNegative RoundTowardPositive a- , Bool -> Word# -> RoundTiesToEven Float- , Bool -> Word# -> RoundTiesToAway Float- , Bool -> Word# -> RoundTowardPositive Float- , Bool -> Word# -> RoundTowardZero Float- , Bool -> Word# -> RoundTiesToEven Double- , Bool -> Word# -> RoundTiesToAway Double- , Bool -> Word# -> RoundTowardPositive Double- , Bool -> Word# -> RoundTowardZero Double- , Bool -> Word# -> Product RoundTowardNegative RoundTowardPositive Float- , Bool -> Word# -> Product RoundTowardNegative RoundTowardPositive Double- #-}+{-# SPECIALIZE positiveWordToBinaryFloatR# :: RoundingStrategy f => Bool -> Word# -> f Float #-}+{-# SPECIALIZE positiveWordToBinaryFloatR# :: RoundingStrategy f => Bool -> Word# -> f Double #-}+{-# SPECIALIZE positiveWordToBinaryFloatR# :: RealFloat a => Bool -> Word# -> RoundTiesToEven a #-}+{-# SPECIALIZE positiveWordToBinaryFloatR# :: RealFloat a => Bool -> Word# -> RoundTiesToAway a #-}+{-# SPECIALIZE positiveWordToBinaryFloatR# :: RealFloat a => Bool -> Word# -> RoundTowardPositive a #-}+{-# SPECIALIZE positiveWordToBinaryFloatR# :: RealFloat a => Bool -> Word# -> RoundTowardZero a #-}+{-# SPECIALIZE positiveWordToBinaryFloatR# :: RealFloat a => Bool -> Word# -> Product RoundTowardNegative RoundTowardPositive a #-}+{-# SPECIALIZE positiveWordToBinaryFloatR# :: Bool -> Word# -> RoundTiesToEven Float #-}+{-# SPECIALIZE positiveWordToBinaryFloatR# :: Bool -> Word# -> RoundTiesToAway Float #-}+{-# SPECIALIZE positiveWordToBinaryFloatR# :: Bool -> Word# -> RoundTowardPositive Float #-}+{-# SPECIALIZE positiveWordToBinaryFloatR# :: Bool -> Word# -> RoundTowardZero Float #-}+{-# SPECIALIZE positiveWordToBinaryFloatR# :: Bool -> Word# -> RoundTiesToEven Double #-}+{-# SPECIALIZE positiveWordToBinaryFloatR# :: Bool -> Word# -> RoundTiesToAway Double #-}+{-# SPECIALIZE positiveWordToBinaryFloatR# :: Bool -> Word# -> RoundTowardPositive Double #-}+{-# SPECIALIZE positiveWordToBinaryFloatR# :: Bool -> Word# -> RoundTowardZero Double #-}+{-# SPECIALIZE positiveWordToBinaryFloatR# :: Bool -> Word# -> Product RoundTowardNegative RoundTowardPositive Float #-}+{-# SPECIALIZE positiveWordToBinaryFloatR# :: Bool -> Word# -> Product RoundTowardNegative RoundTowardPositive Double #-} {-# RULES "positiveWordToBinaryFloatR#/RoundTowardNegative" positiveWordToBinaryFloatR# = \neg x -> RoundTowardNegative (roundTowardPositive (positiveWordToBinaryFloatR# (not neg) x))@@ -291,25 +289,23 @@ !fDigits = floatDigits (undefined :: a) -- 53 for Double (_expMin, !expMax) = floatRange (undefined :: a) -- (-1021, 1024) for Double {-# INLINABLE [0] fromPositiveIntegerR #-}-{-# SPECIALIZE- fromPositiveIntegerR :: RealFloat a => Bool -> Integer -> RoundTiesToEven a- , RealFloat a => Bool -> Integer -> RoundTiesToAway a- , RealFloat a => Bool -> Integer -> RoundTowardPositive a- , RealFloat a => Bool -> Integer -> RoundTowardZero a- , RealFloat a => Bool -> Integer -> Product RoundTowardNegative RoundTowardPositive a- , RoundingStrategy f => Bool -> Integer -> f Double- , RoundingStrategy f => Bool -> Integer -> f Float- , Bool -> Integer -> RoundTiesToEven Double- , Bool -> Integer -> RoundTiesToAway Double- , Bool -> Integer -> RoundTowardPositive Double- , Bool -> Integer -> RoundTowardZero Double- , Bool -> Integer -> RoundTiesToEven Float- , Bool -> Integer -> RoundTiesToAway Float- , Bool -> Integer -> RoundTowardPositive Float- , Bool -> Integer -> RoundTowardZero Float- , Bool -> Integer -> Product RoundTowardNegative RoundTowardPositive Double- , Bool -> Integer -> Product RoundTowardNegative RoundTowardPositive Float- #-}+{-# SPECIALIZE fromPositiveIntegerR :: RealFloat a => Bool -> Integer -> RoundTiesToEven a #-}+{-# SPECIALIZE fromPositiveIntegerR :: RealFloat a => Bool -> Integer -> RoundTiesToAway a #-}+{-# SPECIALIZE fromPositiveIntegerR :: RealFloat a => Bool -> Integer -> RoundTowardPositive a #-}+{-# SPECIALIZE fromPositiveIntegerR :: RealFloat a => Bool -> Integer -> RoundTowardZero a #-}+{-# SPECIALIZE fromPositiveIntegerR :: RealFloat a => Bool -> Integer -> Product RoundTowardNegative RoundTowardPositive a #-}+{-# SPECIALIZE fromPositiveIntegerR :: RoundingStrategy f => Bool -> Integer -> f Double #-}+{-# SPECIALIZE fromPositiveIntegerR :: RoundingStrategy f => Bool -> Integer -> f Float #-}+{-# SPECIALIZE fromPositiveIntegerR :: Bool -> Integer -> RoundTiesToEven Double #-}+{-# SPECIALIZE fromPositiveIntegerR :: Bool -> Integer -> RoundTiesToAway Double #-}+{-# SPECIALIZE fromPositiveIntegerR :: Bool -> Integer -> RoundTowardPositive Double #-}+{-# SPECIALIZE fromPositiveIntegerR :: Bool -> Integer -> RoundTowardZero Double #-}+{-# SPECIALIZE fromPositiveIntegerR :: Bool -> Integer -> RoundTiesToEven Float #-}+{-# SPECIALIZE fromPositiveIntegerR :: Bool -> Integer -> RoundTiesToAway Float #-}+{-# SPECIALIZE fromPositiveIntegerR :: Bool -> Integer -> RoundTowardPositive Float #-}+{-# SPECIALIZE fromPositiveIntegerR :: Bool -> Integer -> RoundTowardZero Float #-}+{-# SPECIALIZE fromPositiveIntegerR :: Bool -> Integer -> Product RoundTowardNegative RoundTowardPositive Double #-}+{-# SPECIALIZE fromPositiveIntegerR :: Bool -> Integer -> Product RoundTowardNegative RoundTowardPositive Float #-} {-# RULES "fromPositiveIntegerR/RoundTowardNegative" fromPositiveIntegerR = \neg x -> RoundTowardNegative (roundTowardPositive (fromPositiveIntegerR (not neg) x))
src/Numeric/Floating/IEEE/Internal/Rounding/Rational.hs view
@@ -125,25 +125,23 @@ !fDigits = floatDigits (undefined :: a) -- 53 for Double (!expMin, !expMax) = floatRange (undefined :: a) -- (-1021, 1024) for Double {-# INLINABLE [0] fromPositiveRatioR #-}-{-# SPECIALIZE- fromPositiveRatioR :: RealFloat a => Bool -> Integer -> Integer -> RoundTiesToEven a- , RealFloat a => Bool -> Integer -> Integer -> RoundTiesToAway a- , RealFloat a => Bool -> Integer -> Integer -> RoundTowardPositive a- , RealFloat a => Bool -> Integer -> Integer -> RoundTowardZero a- , RealFloat a => Bool -> Integer -> Integer -> Product RoundTowardNegative RoundTowardPositive a- , RoundingStrategy f => Bool -> Integer -> Integer -> f Double- , RoundingStrategy f => Bool -> Integer -> Integer -> f Float- , Bool -> Integer -> Integer -> RoundTiesToEven Double- , Bool -> Integer -> Integer -> RoundTiesToAway Double- , Bool -> Integer -> Integer -> RoundTowardPositive Double- , Bool -> Integer -> Integer -> RoundTowardZero Double- , Bool -> Integer -> Integer -> RoundTiesToEven Float- , Bool -> Integer -> Integer -> RoundTiesToAway Float- , Bool -> Integer -> Integer -> RoundTowardPositive Float- , Bool -> Integer -> Integer -> RoundTowardZero Float- , Bool -> Integer -> Integer -> Product RoundTowardNegative RoundTowardPositive Double- , Bool -> Integer -> Integer -> Product RoundTowardNegative RoundTowardPositive Float- #-}+{-# SPECIALIZE fromPositiveRatioR :: RealFloat a => Bool -> Integer -> Integer -> RoundTiesToEven a #-}+{-# SPECIALIZE fromPositiveRatioR :: RealFloat a => Bool -> Integer -> Integer -> RoundTiesToAway a #-}+{-# SPECIALIZE fromPositiveRatioR :: RealFloat a => Bool -> Integer -> Integer -> RoundTowardPositive a #-}+{-# SPECIALIZE fromPositiveRatioR :: RealFloat a => Bool -> Integer -> Integer -> RoundTowardZero a #-}+{-# SPECIALIZE fromPositiveRatioR :: RealFloat a => Bool -> Integer -> Integer -> Product RoundTowardNegative RoundTowardPositive a #-}+{-# SPECIALIZE fromPositiveRatioR :: RoundingStrategy f => Bool -> Integer -> Integer -> f Double #-}+{-# SPECIALIZE fromPositiveRatioR :: RoundingStrategy f => Bool -> Integer -> Integer -> f Float #-}+{-# SPECIALIZE fromPositiveRatioR :: Bool -> Integer -> Integer -> RoundTiesToEven Double #-}+{-# SPECIALIZE fromPositiveRatioR :: Bool -> Integer -> Integer -> RoundTiesToAway Double #-}+{-# SPECIALIZE fromPositiveRatioR :: Bool -> Integer -> Integer -> RoundTowardPositive Double #-}+{-# SPECIALIZE fromPositiveRatioR :: Bool -> Integer -> Integer -> RoundTowardZero Double #-}+{-# SPECIALIZE fromPositiveRatioR :: Bool -> Integer -> Integer -> RoundTiesToEven Float #-}+{-# SPECIALIZE fromPositiveRatioR :: Bool -> Integer -> Integer -> RoundTiesToAway Float #-}+{-# SPECIALIZE fromPositiveRatioR :: Bool -> Integer -> Integer -> RoundTowardPositive Float #-}+{-# SPECIALIZE fromPositiveRatioR :: Bool -> Integer -> Integer -> RoundTowardZero Float #-}+{-# SPECIALIZE fromPositiveRatioR :: Bool -> Integer -> Integer -> Product RoundTowardNegative RoundTowardPositive Double #-}+{-# SPECIALIZE fromPositiveRatioR :: Bool -> Integer -> Integer -> Product RoundTowardNegative RoundTowardPositive Float #-} {-# RULES "fromPositiveRatioR/RoundTowardNegative" fromPositiveRatioR = \neg x y -> RoundTowardNegative (roundTowardPositive (fromPositiveRatioR (not neg) x y))
test/ClassificationSpec.hs view
@@ -29,7 +29,8 @@ , counterexample "isSignMinus" $ isSignMinus x === (c `elem` [NegativeInfinity, NegativeNormal, NegativeSubnormal, NegativeZero]) -- isSignMinus doesn't handle negative NaNs ] where c = classify x-{-# SPECIALIZE prop_classify :: Proxy Float -> Float -> Property, Proxy Double -> Double -> Property #-}+{-# SPECIALIZE prop_classify :: Proxy Float -> Float -> Property #-}+{-# SPECIALIZE prop_classify :: Proxy Double -> Double -> Property #-} prop_totalOrder :: RealFloat a => Proxy a -> a -> a -> Property prop_totalOrder proxy x y = let cmp_x_y = compareByTotalOrder x y@@ -37,7 +38,8 @@ in cmp_x_y === compare EQ cmp_y_x .&&. (if x < y then cmp_x_y === LT else property True) .&&. (if y < x then cmp_x_y === GT else property True)-{-# SPECIALIZE prop_totalOrder :: Proxy Float -> Float -> Float -> Property, Proxy Double -> Double -> Double -> Property #-}+{-# SPECIALIZE prop_totalOrder :: Proxy Float -> Float -> Float -> Property #-}+{-# SPECIALIZE prop_totalOrder :: Proxy Double -> Double -> Double -> Property #-} spec :: Spec spec = do
test/NaNSpec.hs view
@@ -64,7 +64,8 @@ -- , counterexample "class method" $ classify x === classifyDefault x ] where c = classify x-{-# SPECIALIZE prop_classify :: Proxy Float -> Float -> Property, Proxy Double -> Double -> Property #-}+{-# SPECIALIZE prop_classify :: Proxy Float -> Float -> Property #-}+{-# SPECIALIZE prop_classify :: Proxy Double -> Double -> Property #-} isQuietNaN :: (RealFloatNaN a) => a -> Bool isQuietNaN x = isNaN x && not (isSignaling x)