Alex Rivera | Logout

How do I create or test for NaN or infinity in Perl?

Asked 2009-07-26T23:05:08.473
26

How do I create or test for NaN or infinite values in Perl?

Edit
Report

2 Answers

7

Personally, I would use Math::BigFloat (or BigInt) for anything that is going to touch infinity of NaN.

Why reinvent the wheel with a hack solution when there are already modules that do the job?

answered 2009-07-29T08:50:25.993
7

Use Data::Float from CPAN. It exports the following functions:

  • float_is_infinite()
  • float_is_nan()
  • ...

And contrary to the others half-working solutions posted here, it has a testsuite.

answered 2013-03-20T14:58:21.177

Your Answer