isnan() for complex data

Discussion in 'C++' started by jacob navia, Feb 4, 2008.

  1. jacob navia

    jacob navia Guest

    Hi

    Has C++ defined the function
    isnan() for complex numbers?
    What is the definition?

    Thanks in advance
    --
    jacob navia
    jacob at jacob point remcomp point fr
    logiciels/informatique
    http://www.cs.virginia.edu/~lcc-win32
     
    jacob navia, Feb 4, 2008
    #1
    1. Advertising

  2. jacob navia

    Barry Guest

    jacob navia wrote:
    > Hi
    >
    > Has C++ defined the function
    > isnan() for complex numbers?
    > What is the definition?
    >
    > Thanks in advance


    /isnan/ is a macro in C99, still not in the current C++03 standard.

    Synopsis:
    #include <math.h>
    int isnan(real-floating x);

    --
    Best Regards
    Barry
     
    Barry, Feb 4, 2008
    #2
    1. Advertising

  3. jacob navia

    jacob navia Guest

    Barry wrote:
    > jacob navia wrote:
    >> Hi
    >>
    >> Has C++ defined the function
    >> isnan() for complex numbers?
    >> What is the definition?
    >>
    >> Thanks in advance

    >
    > /isnan/ is a macro in C99, still not in the current C++03 standard.
    >
    > Synopsis:
    > #include <math.h>
    > int isnan(real-floating x);
    >


    In C99 this is ONLY defined for real types. No definition for
    complex types. What is the definition in C++?

    is it

    insan(z) --> isnan(real(z) || isnan(imag(z)

    or

    insan(z) --> isnan(real(z) && isnan(imag(z)

    ???

    The same problem appears for

    isinf()


    --
    jacob navia
    jacob at jacob point remcomp point fr
    logiciels/informatique
    http://www.cs.virginia.edu/~lcc-win32
     
    jacob navia, Feb 4, 2008
    #3
  4. jacob navia

    jacob navia Guest

    jacob navia wrote:
    >
    > In C99 this is ONLY defined for real types. No definition for
    > complex types. What is the definition in C++?
    >
    > is it
    >
    > insan(z) --> isnan(real(z) || isnan(imag(z)


    excuse me that should have been

    > insan(z) --> isnan(real(z)) || isnan(imag(z))


    with correctly matched parentheses!



    >
    > or
    >
    > insan(z) --> isnan(real(z) && isnan(imag(z)


    The same
    insan(z) --> isnan(real(z)) && isnan(imag(z))



    --
    jacob navia
    jacob at jacob point remcomp point fr
    logiciels/informatique
    http://www.cs.virginia.edu/~lcc-win32
     
    jacob navia, Feb 4, 2008
    #4
  5. jacob navia

    ciccio Guest

    jacob navia wrote:
    > jacob navia wrote:
    >>
    >> In C99 this is ONLY defined for real types. No definition for
    >> complex types. What is the definition in C++?


    >> insan(z) --> isnan(real(z)) || isnan(imag(z))


    If you want to program an "isnan" function for std::complex<T>, then I
    suggest you to use the above function.

    If one of the parts is an invalid real number then your whole complex
    number should be invalid.

    The same reasoning goes for isinf. If one of your complex numbers is
    infinite, then your complex number is one of the many representations of
    infinite.

    Klaas
     
    ciccio, Feb 5, 2008
    #5
  6. jacob navia

    Barry Guest

    jacob navia wrote:
    > jacob navia wrote:
    >>
    >> In C99 this is ONLY defined for real types. No definition for
    >> complex types. What is the definition in C++?
    >>
    >> is it
    >>
    >> insan(z) --> isnan(real(z) || isnan(imag(z)

    >
    > excuse me that should have been
    >
    > > insan(z) --> isnan(real(z)) || isnan(imag(z))

    >
    > with correctly matched parentheses!
    >
    >
    >
    >>
    >> or
    >>
    >> insan(z) --> isnan(real(z) && isnan(imag(z)

    >
    > The same
    > insan(z) --> isnan(real(z)) && isnan(imag(z))
    >
    >
    >

    I think C++ will expand nothing but syntactic sugar(template function).

    According to C++0x draft (here, N2315).

    26.7 [c.math]

    12
    The templates defined in <cmath> replace the C99 macros with the same
    names. The templates have the following
    declarations:

    ....

    template <class T> bool isnan(T x);

    ....

    13
    The templates behave the same as the C99 macros with corresponding names
    defined in C99 subclause 7.12.3, Classification macros, and C99
    subclause 7.12.14, Comparison macros.
    SEE ALSO: ISO C subclauses 7.5, 7.10.2, 7.10.6.


    --
    Best Regards
    Barry
     
    Barry, Feb 5, 2008
    #6
    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,802
    =?Utf-8?B?c2lhag==?=
    Mar 8, 2005
  2. Christopher Benson-Manica
    Replies:
    0
    Views:
    434
    Christopher Benson-Manica
    May 11, 2004
  3. Skybuck Flying
    Replies:
    5
    Views:
    868
  4. Priya

    isinf() & isnan()

    Priya, Sep 19, 2006, in forum: C++
    Replies:
    2
    Views:
    637
    Priya
    Sep 19, 2006
  5. JohnF

    isnan or isntnan?

    JohnF, Nov 13, 2010, in forum: C Programming
    Replies:
    34
    Views:
    1,628
Loading...

Share This Page