如何在Haskell中产生无穷大? [英] How to produce infinity in Haskell?

查看:101
本文介绍了如何在Haskell中产生无穷大?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

简单地如何在Haskell中生产NaN ..

在C中,有一个INFINITY宏,由math.h定义.

再次在 http://hackage.haskell中进行. org/package/ClassyPrelude-0.1/docs/Prelude-Math.html 我可以看到测试无罪的手段,但是却没有.

因此,我唯一的选择是1/0之类的东西吗?

解决方案

iee754 软件包具有特定于该浮点格式的函数和常量.

尤其是,对于IEEE类的成员(其float和double属于),它具有Numeric.IEEE.infinity常量.不过,它几乎只是实现为1/0,因此,如果您希望将程序包相关性作为更漂亮的名称,则可以进行调用.

Similarily to How to produce a NaN in Haskell ...

In C, there is the INFINITY macro, defined by math.h.

Again, in http://hackage.haskell.org/package/ClassyPrelude-0.1/docs/Prelude-Math.html I can see falicities to test for infnity, but not to produce one.

Therefore, is my only choice something like 1/0?

解决方案

The iee754 package has functions and constants specific to that floating point format.

In particular, it has the Numeric.IEEE.infinity constant for members for the IEEE class (which float and double belong to). It is pretty much just implemented as 1/0 though, so your call if you want the package dependency for a prettier name.

这篇关于如何在Haskell中产生无穷大?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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