Plan 9 from Bell Labs’s /usr/web/sources/contrib/fernan/nhc98/src/prelude/Prelude/RealFloat_Float.hs

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


module Prelude(RealFloat(..)) where

import PrimDecodeFloat
import PrimEncodeFloat
import CRealFloat

-- WARNING 32bit IEEE float

instance  RealFloat Float  where
    floatRadix _  = 2          -- FLT_RADIX
    floatDigits _ = 24         -- FLT_DIGITS
    floatRange _  = (negate 148,128) -- (FLT_MINEXP, FLT_MAXEXP)
    decodeFloat x = primDecodeFloat x
    encodeFloat x y = primEncodeFloat x y

    -- TODO
    isNaN x 	     = cFIsNaN x
    isInfinite x     = not (cFIsFinite x)
    isDenormalized x = not (cFIsNormal x)
    isNegativeZero x = cFIsNeg x && (x==0.0)
    isIEEE x         = True

foreign import noproto "math.h isnan"    cFIsNaN    :: Float -> Bool
foreign import noproto "math.h isfinite" cFIsFinite :: Float -> Bool
foreign import noproto "math.h isnormal" cFIsNormal :: Float -> Bool
foreign import noproto "math.h signbit"  cFIsNeg    :: Float -> Bool

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].