-
March 4th, 2016, 11:03 AM
#1
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
-
March 4th, 2016, 11:36 AM
#2
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++23 Compiler: Microsoft VS2022 (17.6.5)
-
March 4th, 2016, 03:55 PM
#3
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
-
March 4th, 2016, 04:29 PM
#4
Re: floating point invalid operation
Originally Posted by adamle
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
-
March 4th, 2016, 04:42 PM
#5
Re: floating point invalid operation
Originally Posted by adamle
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++23 Compiler: Microsoft VS2022 (17.6.5)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|