{-# LANGUAGE DataKinds #-}
{-# LANGUAGE HexFloatLiterals #-}
module Numeric.Rounded.Hardware.Internal.Constants where
import Numeric.Rounded.Hardware.Internal.Rounding

class RealFloatConstants a where
  -- | \(+\infty\)
  positiveInfinity :: a
  -- | \(-\infty\)
  negativeInfinity :: a
  maxFinite :: a
  -- minPositiveNormal :: a
  minPositive :: a

  -- | The correctly-rounded value of \(\pi\)
  pi_down :: Rounded 'TowardNegInf a
  -- | The correctly-rounded value of \(\pi\)
  pi_up :: Rounded 'TowardInf a

  -- | The correctly-rounded value of \(3\pi\)
  three_pi_down :: Rounded 'TowardNegInf a
  -- | The correctly-rounded value of \(3\pi\)
  three_pi_up :: Rounded 'TowardInf a

  -- | The correctly-rounded value of \(5\pi\)
  five_pi_down :: Rounded 'TowardNegInf a
  -- | The correctly-rounded value of \(5\pi\)
  five_pi_up :: Rounded 'TowardInf a

  -- | The correctly-rounded value of \(\log_e 2\)
  log2_down :: Rounded 'TowardNegInf a
  -- | The correctly-rounded value of \(\log_e 2\)
  log2_up :: Rounded 'TowardInf a

  -- | The correctly-rounded value of \(\exp(1)\)
  exp1_down :: Rounded 'TowardNegInf a
  -- | The correctly-rounded value of \(\exp(1)\)
  exp1_up :: Rounded 'TowardInf a

  -- | The correctly-rounded value of \(\exp(1/2)\)
  exp1_2_down :: Rounded 'TowardNegInf a
  -- | The correctly-rounded value of \(\exp(1/2)\)
  exp1_2_up :: Rounded 'TowardInf a

  -- | The correctly-rounded value of \(\exp(-1/2)\)
  expm1_2_down :: Rounded 'TowardNegInf a
  -- | The correctly-rounded value of \(\exp(-1/2)\)
  expm1_2_up :: Rounded 'TowardInf a

  -- | The correctly-rounded value of \(\sqrt{2}\)
  sqrt2_down :: Rounded 'TowardNegInf a
  -- | The correctly-rounded value of \(\sqrt{2}\)
  sqrt2_up :: Rounded 'TowardInf a

  -- | The correctly-rounded value of \(\sqrt{2}-1\)
  sqrt2m1_down :: Rounded 'TowardNegInf a
  -- | The correctly-rounded value of \(\sqrt{2}-1\)
  sqrt2m1_up :: Rounded 'TowardInf a

  -- | The correctly-rounded value of \(1/\sqrt{2}\)
  sqrt1_2_down :: Rounded 'TowardNegInf a
  -- | The correctly-rounded value of \(1/\sqrt{2}\)
  sqrt1_2_up :: Rounded 'TowardInf a

  -- | The correctly-rounded value of \(3-2\sqrt{2}\)
  three_minus_2sqrt2_down :: Rounded 'TowardNegInf a
  -- | The correctly-rounded value of \(3-2\sqrt{2}\)
  three_minus_2sqrt2_up :: Rounded 'TowardInf a

  -- | The correctly-rounded value of \(2-\sqrt{2}\)
  two_minus_sqrt2_down :: Rounded 'TowardNegInf a
  -- | The correctly-rounded value of \(2-\sqrt{2}\)
  two_minus_sqrt2_up :: Rounded 'TowardInf a

instance RealFloatConstants Double where
  positiveInfinity :: Double
positiveInfinity = Double
1Double -> Double -> Double
forall a. Fractional a => a -> a -> a
/Double
0
  negativeInfinity :: Double
negativeInfinity = -Double
1Double -> Double -> Double
forall a. Fractional a => a -> a -> a
/Double
0
  maxFinite :: Double
maxFinite = Double
0x1.fffffffffffffp+1023
  -- minPositiveNormal = 0x1p-1022
  minPositive :: Double
minPositive = Double
0x1p-1074 -- subnormal
  -- (pi :: Double) == 0x1.921fb54442d18p1
  pi_down :: Rounded 'TowardNegInf Double
pi_down = Double -> Rounded 'TowardNegInf Double
forall (r :: RoundingMode) a. a -> Rounded r a
Rounded Double
0x1.921fb54442d18p+1
  pi_up :: Rounded 'TowardInf Double
pi_up   = Double -> Rounded 'TowardInf Double
forall (r :: RoundingMode) a. a -> Rounded r a
Rounded Double
0x1.921fb54442d19p+1
  -- 3*pi
  three_pi_down :: Rounded 'TowardNegInf Double
three_pi_down = Double -> Rounded 'TowardNegInf Double
forall (r :: RoundingMode) a. a -> Rounded r a
Rounded Double
0x1.2d97c7f3321d2p+3
  three_pi_up :: Rounded 'TowardInf Double
three_pi_up   = Double -> Rounded 'TowardInf Double
forall (r :: RoundingMode) a. a -> Rounded r a
Rounded Double
0x1.2d97c7f3321d3p+3
  -- 5*pi
  five_pi_down :: Rounded 'TowardNegInf Double
five_pi_down = Double -> Rounded 'TowardNegInf Double
forall (r :: RoundingMode) a. a -> Rounded r a
Rounded Double
0x1.f6a7a2955385ep+3
  five_pi_up :: Rounded 'TowardInf Double
five_pi_up   = Double -> Rounded 'TowardInf Double
forall (r :: RoundingMode) a. a -> Rounded r a
Rounded Double
0x1.f6a7a2955385fp+3
  -- log(2)
  log2_down :: Rounded 'TowardNegInf Double
log2_down = Double -> Rounded 'TowardNegInf Double
forall (r :: RoundingMode) a. a -> Rounded r a
Rounded Double
0x1.62e42fefa39efp-1
  log2_up :: Rounded 'TowardInf Double
log2_up   = Double -> Rounded 'TowardInf Double
forall (r :: RoundingMode) a. a -> Rounded r a
Rounded Double
0x1.62e42fefa39f0p-1
  -- exp(1)
  exp1_down :: Rounded 'TowardNegInf Double
exp1_down = Double -> Rounded 'TowardNegInf Double
forall (r :: RoundingMode) a. a -> Rounded r a
Rounded Double
0x1.5bf0a8b145769p+1
  exp1_up :: Rounded 'TowardInf Double
exp1_up   = Double -> Rounded 'TowardInf Double
forall (r :: RoundingMode) a. a -> Rounded r a
Rounded Double
0x1.5bf0a8b14576ap+1
  -- exp(1/2)
  exp1_2_down :: Rounded 'TowardNegInf Double
exp1_2_down = Double -> Rounded 'TowardNegInf Double
forall (r :: RoundingMode) a. a -> Rounded r a
Rounded Double
0x1.a61298e1e069bp+0
  exp1_2_up :: Rounded 'TowardInf Double
exp1_2_up   = Double -> Rounded 'TowardInf Double
forall (r :: RoundingMode) a. a -> Rounded r a
Rounded Double
0x1.a61298e1e069cp+0
  -- exp(-1/2)
  expm1_2_down :: Rounded 'TowardNegInf Double
expm1_2_down = Double -> Rounded 'TowardNegInf Double
forall (r :: RoundingMode) a. a -> Rounded r a
Rounded Double
0x1.368b2fc6f9609p-1
  expm1_2_up :: Rounded 'TowardInf Double
expm1_2_up   = Double -> Rounded 'TowardInf Double
forall (r :: RoundingMode) a. a -> Rounded r a
Rounded Double
0x1.368b2fc6f960ap-1
  -- sqrt(2)
  sqrt2_down :: Rounded 'TowardNegInf Double
sqrt2_down = Double -> Rounded 'TowardNegInf Double
forall (r :: RoundingMode) a. a -> Rounded r a
Rounded Double
0x1.6a09e667f3bccp+0
  sqrt2_up :: Rounded 'TowardInf Double
sqrt2_up   = Double -> Rounded 'TowardInf Double
forall (r :: RoundingMode) a. a -> Rounded r a
Rounded Double
0x1.6a09e667f3bcdp+0
  -- sqrt(1/2)
  sqrt1_2_down :: Rounded 'TowardNegInf Double
sqrt1_2_down = Double -> Rounded 'TowardNegInf Double
forall (r :: RoundingMode) a. a -> Rounded r a
Rounded Double
0x1.6a09e667f3bccp-1
  sqrt1_2_up :: Rounded 'TowardInf Double
sqrt1_2_up   = Double -> Rounded 'TowardInf Double
forall (r :: RoundingMode) a. a -> Rounded r a
Rounded Double
0x1.6a09e667f3bcdp-1
  -- sqrt(2)-1
  sqrt2m1_down :: Rounded 'TowardNegInf Double
sqrt2m1_down = Double -> Rounded 'TowardNegInf Double
forall (r :: RoundingMode) a. a -> Rounded r a
Rounded Double
0x1.a827999fcef32p-2
  sqrt2m1_up :: Rounded 'TowardInf Double
sqrt2m1_up   = Double -> Rounded 'TowardInf Double
forall (r :: RoundingMode) a. a -> Rounded r a
Rounded Double
0x1.a827999fcef33p-2
  -- 3 - 2 * sqrt(2)
  three_minus_2sqrt2_down :: Rounded 'TowardNegInf Double
three_minus_2sqrt2_down = Double -> Rounded 'TowardNegInf Double
forall (r :: RoundingMode) a. a -> Rounded r a
Rounded Double
0x1.5f619980c4336p-3
  three_minus_2sqrt2_up :: Rounded 'TowardInf Double
three_minus_2sqrt2_up   = Double -> Rounded 'TowardInf Double
forall (r :: RoundingMode) a. a -> Rounded r a
Rounded Double
0x1.5f619980c4337p-3
  -- 2 - sqrt(2)
  two_minus_sqrt2_down :: Rounded 'TowardNegInf Double
two_minus_sqrt2_down = Double -> Rounded 'TowardNegInf Double
forall (r :: RoundingMode) a. a -> Rounded r a
Rounded Double
0x1.2bec333018866p-1
  two_minus_sqrt2_up :: Rounded 'TowardInf Double
two_minus_sqrt2_up   = Double -> Rounded 'TowardInf Double
forall (r :: RoundingMode) a. a -> Rounded r a
Rounded Double
0x1.2bec333018867p-1
  {-# INLINE positiveInfinity #-}
  {-# INLINE negativeInfinity #-}
  {-# INLINE maxFinite #-}
  {-# INLINE minPositive #-}

instance RealFloatConstants Float where
  positiveInfinity :: Float
positiveInfinity = Float
1Float -> Float -> Float
forall a. Fractional a => a -> a -> a
/Float
0
  negativeInfinity :: Float
negativeInfinity = -Float
1Float -> Float -> Float
forall a. Fractional a => a -> a -> a
/Float
0
  maxFinite :: Float
maxFinite = Float
0x1.fffffep+127
  minPositive :: Float
minPositive = Float
0x1p-149
  pi_down :: Rounded 'TowardNegInf Float
pi_down = Float -> Rounded 'TowardNegInf Float
forall (r :: RoundingMode) a. a -> Rounded r a
Rounded Float
0x1.921fb4p+1
  pi_up :: Rounded 'TowardInf Float
pi_up   = Float -> Rounded 'TowardInf Float
forall (r :: RoundingMode) a. a -> Rounded r a
Rounded Float
0x1.921fb6p+1
  -- 3*pi
  three_pi_down :: Rounded 'TowardNegInf Float
three_pi_down = Float -> Rounded 'TowardNegInf Float
forall (r :: RoundingMode) a. a -> Rounded r a
Rounded Float
0x1.2d97c6p+3
  three_pi_up :: Rounded 'TowardInf Float
three_pi_up   = Float -> Rounded 'TowardInf Float
forall (r :: RoundingMode) a. a -> Rounded r a
Rounded Float
0x1.2d97c8p+3
  -- 5*pi
  five_pi_down :: Rounded 'TowardNegInf Float
five_pi_down = Float -> Rounded 'TowardNegInf Float
forall (r :: RoundingMode) a. a -> Rounded r a
Rounded Float
0x1.f6a7a2p+3
  five_pi_up :: Rounded 'TowardInf Float
five_pi_up   = Float -> Rounded 'TowardInf Float
forall (r :: RoundingMode) a. a -> Rounded r a
Rounded Float
0x1.f6a7a4p+3
  -- log(2)
  log2_down :: Rounded 'TowardNegInf Float
log2_down = Float -> Rounded 'TowardNegInf Float
forall (r :: RoundingMode) a. a -> Rounded r a
Rounded Float
0x1.62e42ep-1
  log2_up :: Rounded 'TowardInf Float
log2_up   = Float -> Rounded 'TowardInf Float
forall (r :: RoundingMode) a. a -> Rounded r a
Rounded Float
0x1.62e430p-1
  -- exp(1)
  exp1_down :: Rounded 'TowardNegInf Float
exp1_down = Float -> Rounded 'TowardNegInf Float
forall (r :: RoundingMode) a. a -> Rounded r a
Rounded Float
0x1.5bf0a8p+1
  exp1_up :: Rounded 'TowardInf Float
exp1_up   = Float -> Rounded 'TowardInf Float
forall (r :: RoundingMode) a. a -> Rounded r a
Rounded Float
0x1.5bf0aap+1
  -- exp(1/2)
  exp1_2_down :: Rounded 'TowardNegInf Float
exp1_2_down = Float -> Rounded 'TowardNegInf Float
forall (r :: RoundingMode) a. a -> Rounded r a
Rounded Float
0x1.a61298p+0
  exp1_2_up :: Rounded 'TowardInf Float
exp1_2_up   = Float -> Rounded 'TowardInf Float
forall (r :: RoundingMode) a. a -> Rounded r a
Rounded Float
0x1.a6129ap+0
  -- exp(-1/2)
  expm1_2_down :: Rounded 'TowardNegInf Float
expm1_2_down = Float -> Rounded 'TowardNegInf Float
forall (r :: RoundingMode) a. a -> Rounded r a
Rounded Float
0x1.368b2ep-1
  expm1_2_up :: Rounded 'TowardInf Float
expm1_2_up   = Float -> Rounded 'TowardInf Float
forall (r :: RoundingMode) a. a -> Rounded r a
Rounded Float
0x1.368b30p-1
  -- sqrt(2)
  sqrt2_down :: Rounded 'TowardNegInf Float
sqrt2_down = Float -> Rounded 'TowardNegInf Float
forall (r :: RoundingMode) a. a -> Rounded r a
Rounded Float
0x1.6a09e6p+0
  sqrt2_up :: Rounded 'TowardInf Float
sqrt2_up   = Float -> Rounded 'TowardInf Float
forall (r :: RoundingMode) a. a -> Rounded r a
Rounded Float
0x1.6a09e8p+0
  -- sqrt(1/2)
  sqrt1_2_down :: Rounded 'TowardNegInf Float
sqrt1_2_down = Float -> Rounded 'TowardNegInf Float
forall (r :: RoundingMode) a. a -> Rounded r a
Rounded Float
0x1.6a09e6p-1
  sqrt1_2_up :: Rounded 'TowardInf Float
sqrt1_2_up   = Float -> Rounded 'TowardInf Float
forall (r :: RoundingMode) a. a -> Rounded r a
Rounded Float
0x1.6a09e8p-1
  -- sqrt(2)-1
  sqrt2m1_down :: Rounded 'TowardNegInf Float
sqrt2m1_down = Float -> Rounded 'TowardNegInf Float
forall (r :: RoundingMode) a. a -> Rounded r a
Rounded Float
0x1.a82798p-2
  sqrt2m1_up :: Rounded 'TowardInf Float
sqrt2m1_up   = Float -> Rounded 'TowardInf Float
forall (r :: RoundingMode) a. a -> Rounded r a
Rounded Float
0x1.a8279ap-2
  -- 3 - 2 * sqrt(2)
  three_minus_2sqrt2_down :: Rounded 'TowardNegInf Float
three_minus_2sqrt2_down = Float -> Rounded 'TowardNegInf Float
forall (r :: RoundingMode) a. a -> Rounded r a
Rounded Float
0x1.5f6198p-3
  three_minus_2sqrt2_up :: Rounded 'TowardInf Float
three_minus_2sqrt2_up   = Float -> Rounded 'TowardInf Float
forall (r :: RoundingMode) a. a -> Rounded r a
Rounded Float
0x1.5f619ap-3
  -- 2 - sqrt(2)
  two_minus_sqrt2_down :: Rounded 'TowardNegInf Float
two_minus_sqrt2_down = Float -> Rounded 'TowardNegInf Float
forall (r :: RoundingMode) a. a -> Rounded r a
Rounded Float
0x1.2bec32p-1
  two_minus_sqrt2_up :: Rounded 'TowardInf Float
two_minus_sqrt2_up   = Float -> Rounded 'TowardInf Float
forall (r :: RoundingMode) a. a -> Rounded r a
Rounded Float
0x1.2bec34p-1
  {-# INLINE positiveInfinity #-}
  {-# INLINE negativeInfinity #-}
  {-# INLINE maxFinite #-}
  {-# INLINE minPositive #-}