URL:
<http://gna.org/bugs/?11713>
Summary: NAN (not a number) is not enough portable to use it
directly
Project: Wormux
Submitted by: gentildemon
Submitted on: mercredi 21.05.2008 à 21:36
Category: Compilation
Severity: 3 - Normal
Priority: 7 - High
Status: Confirmed
Assigned to: None
Originator Email:
Open/Closed: Open
Release: 0.8
Discussion Lock: Any
_______________________________________________________
Details:
NAN is a constant conforming to C99.
C++ has been defined before C99, thus NAN is not always available.
We handled function isnan() with various #ifdef #define in src/tool/isnan.h
[A strange property: "if x != x then x is NaN"
(see http://en.wikipedia.org/wiki/NaN)]
NAN is defined as one the value for which isnan(value) == true
NAN is undefined on OpenBSD as OpenBSD runs on CPU not following IEEE
floating points number.
(interesting mail thread about NAN and OpenBSD :
http://www.nabble.com/Where-is-NAN-Defined--td15398150.html)
Wormux 0.7.9 has been build on OpenBSD with
#ifndef NAN
#define NAN (0.0/atof("?"))
#endif
From "double Ground::Tangent(int x,int y)" in src/map/ground.cpp, you can
see:
#ifdef _MSC_VER
const unsigned long nan[2] ={0xffffffff, 0x7fffffff};
return *( double* )nan;
#else
return NAN;
#endif
So I suppose that NAN is not defined when compiling with MS Visual Studio.
Here we have 2 different definitions of NAN, we must, at least, push it in
src/tool/isnan.h
Maybe we can add a test to check NAN/isNaN definition, something like:
double not_a_number = NAN;
if (isNaN(not_a_number))
printf("Your implementation of NAN/isNaN is ok\n");
else {
printf("Wrong implementation of NAN/isNaN. Please check
src/tool/isnan.h\n");
exit(1);
}
_______________________________________________________
Reply to this item at:
<http://gna.org/bugs/?11713>
_______________________________________________
Message posté via/par Gna!
http://gna.org/
_______________________________________________
Wormux-gna mailing list
[email protected]
https://mail.gna.org/listinfo/wormux-gna