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

吃可爱长大的小学妹 提交于 2019-12-03 10:26: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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!