Yac*_*oby 5 numerical haskell types integer
我在Haskell中编写一个函数来处理超过32位int的数字.我找不到这种类型,我似乎在寻找错误的术语.
它需要能够保持大约2 ^ 40的数字,而不会损失任何精度
例:
addTwo :: Int -> Int -> Int
addTwo a b = a + b
main :: IO()
main = do
putStrLn ( show ( addTwo 700851475143 1 ) )
Run Code Online (Sandbox Code Playgroud)
您想要Integer
数据类型而不是Int
:
addTwo :: Integer -> Integer -> Integer
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1665 次 |
最近记录: |