GHC的Int类型的位大小 [英] Bit Size of GHC's Int Type

查看:96
本文介绍了GHC的Int类型的位大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么GHC的Int type 不能保证精确使用32位精度? 此文档声明它具有至少<30>有符号精度。它与装配 Maybe Int 或类似到32位有什么关系?

Why is GHC's Int type not guaranteed to use exactly 32 bits of precision? This document claim it has at least 30-bit signed precision. Is it somehow related to fitting Maybe Int or similar into 32-bits?

推荐答案

它允许使用标记的Haskell的实现。使用标记时,您需要一些标记(至少一个,两个更好)。我不确定目前有没有这样的实现,但我似乎记得耶鲁的Haskell使用它。

It is to allow implementations of Haskell that use tagging. When using tagging you need a few bits as tags (at least one, two is better). I'm not sure there currently are any such implementations, but I seem to remember Yale Haskell used it.

标记可以避免拳击的缺点,因为你不再必须把所有东西都装箱相反,标签位会告诉你它是否被评估等。

Tagging can somewhat avoid the disadvantages of boxing, since you no longer have to box everything; instead the tag bit will tell you if it's evaluated etc.

这篇关于GHC的Int类型的位大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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