Int和Integer有什么区别? [英] What is the difference between Int and Integer?

查看:232
本文介绍了Int和Integer有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Haskell中, Int Integer 之间有什么区别?

解决方案


Integer是一个任意精度
类型:它会保存任何数字,不论
有多大,最高达
您机器的内存限制......。这意味着你永远不会有
算术溢出。在另一个
手上,这也意味着你的算术是
相对较慢。 Lisp用户可能
认可这里的bignum类型。
$ b $Int是更常见的32或64位
整数。实现方式有所不同,
虽然保证在
至少30位。


来源: Haskell Wikibook 。另外,您可能会发现 Haskell简介的 Numbers 部分 em>有用。

In Haskell, what is the difference between an Int and an Integer? Where is the answer documented?

解决方案

"Integer" is an arbitrary precision type: it will hold any number no matter how big, up to the limit of your machine's memory…. This means you never have arithmetic overflows. On the other hand it also means your arithmetic is relatively slow. Lisp users may recognise the "bignum" type here.

"Int" is the more common 32 or 64 bit integer. Implementations vary, although it is guaranteed to be at least 30 bits.

Source: The Haskell Wikibook. Also, you may find the Numbers section of A Gentle Introduction to Haskell useful.

这篇关于Int和Integer有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆