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

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

问题描述

在 Haskell 中,IntInteger 有什么区别?答案记录在哪里?

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

推荐答案

整数"是任意精度类型:它将保存任何数字不管多大,到极限你机器的内存……这意味着你从来没有算术溢出.在另一手这也意味着你的算术是比较慢.Lisp 用户可以在这里识别bignum"类型.

"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"是更常见的 32 位或 64 位整数.实现方式不同,虽然它保证在至少 30 位.

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

来源:Haskell Wikibook.此外,您还可以在 Haskell 简介 中找到 Numbers 部分em> 有用.

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

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

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