isnan(), fpclassify()

Discussion in 'Perl Misc' started by BZ, Aug 24, 2005.

  1. BZ

    BZ Guest

    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


    --
    BZ
     
    BZ, Aug 24, 2005
    #1
    1. Advertising

  2. BZ

    Paul Lalli Guest

    BZ wrote:
    > 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
     
    Paul Lalli, Aug 24, 2005
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?c2lhag==?=

    isNaN function jscript

    =?Utf-8?B?c2lhag==?=, Mar 8, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    2,828
    =?Utf-8?B?c2lhag==?=
    Mar 8, 2005
  2. Christopher Benson-Manica
    Replies:
    0
    Views:
    441
    Christopher Benson-Manica
    May 11, 2004
  3. Skybuck Flying
    Replies:
    5
    Views:
    900
  4. Priya

    isinf() & isnan()

    Priya, Sep 19, 2006, in forum: C++
    Replies:
    2
    Views:
    645
    Priya
    Sep 19, 2006
  5. jacob navia

    isnan() for complex data

    jacob navia, Feb 4, 2008, in forum: C++
    Replies:
    5
    Views:
    552
    Barry
    Feb 5, 2008
Loading...

Share This Page