isnan(), fpclassify()

B

BZ

Hi!

I was wondering if the functionality of the C99 function isnan(),
isinf() and fp_classify() are available in perl.

Or even better, is it possible to get printf to recognise things like
'nan' and 'inf' as floats? They seems to be interpreted as text by
default:

[bas@matilda]~> perl -e 'printf "%e %e %e %e\n", "123", "nan", "inf", "-inf";'
1.230000e+02 0.000000e+00 0.000000e+00 -0.000000e+00
 
P

Paul Lalli

BZ said:
I was wondering if the functionality of the C99 function isnan(),
isinf() and fp_classify() are available in perl.

Or even better, is it possible to get printf to recognise things like
'nan' and 'inf' as floats?

Have a look at the Math::BigFloat module
(http://search.cpan.org/~tels/Math-BigInt-1.77/lib/Math/BigFloat.pm)
and see if that suits your needs.
They seems to be interpreted as text by
default:

[bas@matilda]~> perl -e 'printf "%e %e %e %e\n", "123", "nan", "inf", "-inf";'
1.230000e+02 0.000000e+00 0.000000e+00 -0.000000e+00

Correct. Any string that does not "look" like a number is treated as
the number 0 in numeric context.

Paul Lalli
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top