如何在Haskell中产生无穷大?

编程入门 行业动态 更新时间:2024-10-18 10:27:49
本文介绍了如何在Haskell中产生无穷大?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

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

再次在 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 hackage.haskell/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中产生无穷大?

本文发布于:2023-11-02 17:09:47,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1552950.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:无穷大   如何在   Haskell

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!