简单地如何在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中产生无穷大?
发布评论