问题
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
?
回答1:
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.
来源:https://stackoverflow.com/questions/55902511/how-to-produce-a-nan-in-haskell