Is it possible to use extended precision (80-bit) floating point arithmetic in GHC/Haskell?

后端 未结 1 1357
野的像风
野的像风 2021-02-13 05:48

The standard Haskell\'s Double uses the standard double-precision arithmetic:

data Double Double-precision floating point numbers. It is de

相关标签:
1条回答
  • 2021-02-13 06:56

    As chuff has pointed out, you might want to take a look a the numbers package on hackage. You can install it with cabal install numbers. Here is an example:

    import Data.Number.CReal -- from numbers
    
    main :: IO ()
    main = putStrLn (showCReal 100 (sqrt 2))
    
    -- output: 1.4142135623730950488016887242096980785696718753769480731766797379907324784621070388503875343276415727
    

    As the documentation states, showCReal returns a string showing a given number of type CReal with the given number of decimals.

    0 讨论(0)
提交回复
热议问题