dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: floating point invalid operation

  1. #1
    Join Date
    Mar 2016
    Posts
    2

    floating point invalid operation

    Hey all,

    Actually I have a problem while trying to check whether a pointer has +NaN or -NaN. Variable is defined as an extern float pointer. I have used x!=x, _isnan function and many more methods. All these methods raise an error saying floating point invalid operation. Please help me to solve this issue.

    Example line where it raises an exception is:
    bool nan = _isnan(x);

    Environment: Embarcadero C++ builder XE2

    Ashwini

  2. #2
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,036

    Re: floating point invalid operation

    Variable is defined as an extern float pointer
    if x is the pointer, then don't you mean
    Code:
    bool nan = isnan(*x);
    Also why use _isnan()? Why not the c++ isnan() from <cmath> ? See http://www.cplusplus.com/reference/cmath/isnan/
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++17 Compiler: Microsoft VS2019 (16.5.1)

  3. #3
    Join Date
    Mar 2016
    Posts
    2

    Re: floating point invalid operation

    Actually I am dereferencing the pointer in a for loop.
    Also I am not able detect isnan() macro in <cmath> library

  4. #4
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    19,624

    Re: floating point invalid operation

    Quote Originally Posted by adamle View Post
    Actually I am dereferencing the pointer in a for loop.
    Also I am not able detect isnan() macro in <cmath> library
    Why don't you want to show your actual code?
    Victor Nijegorodov

  5. #5
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,036

    Re: floating point invalid operation

    Quote Originally Posted by adamle View Post
    Actually I am dereferencing the pointer in a for loop.
    Also I am not able detect isnan() macro in <cmath> library
    isnan() within <cmath> is part of the c++11 standard - so Builder XE2 mustn't be c++11 compliant. Have you considered upgrading to a c++11/14 compliant version/compiler?
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++17 Compiler: Microsoft VS2019 (16.5.1)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)