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


in reply to How do I create/detect/handle Infinity?

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.