问题描述
简单地如何在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中产生无穷大?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!