http://www.perlmonks.org?node_id=783074

Q&A > math > How do I create/detect/handle Infinity? - Answer contributed by moritz

I think in Perl 5 this is platform specific, so I'll rather give the Perl 6 answer:
my $num = Inf; given $num { say "+Inf" when Inf; say "-Inf" when -Inf; say "NaN" when NaN; }

Works in Rakudo today.