From: SourceForge.net <no...@so...> - 2008-10-30 14:22:47
|
Bugs item #2207721, was opened at 2008-10-29 17:40 Message generated for change (Comment added) made by tammer You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=684730&aid=2207721&group_id=119701 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: APIs Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Mark Miesfeld (miesfeld) Assigned to: Nobody/Anonymous (nobody) Summary: ObjectToDouble(nan) native API failure on AIX Initial Comment: Hi Rick, Think I need help with this one too. Rather than post to the list, I thought I'd open up a bug so you can look at it when you have time. On AIX, in the CONVERSION.testGroup these types of test cases are failing: val = "nan" self~assertSame(val, .CONVERSIONTester~TestObjectToDouble(val)) Rather than nan, they are producing +infinity [failure] [20081029 16:31:13.155443] svn: r3371 Change date: 2008-09-21 06:33:29 +0200 Test: TESTDOUBLE03 Class: CONVERSION.testGroup File: /daten/svn/ooRexx/test/trunk/ooRexx/API/oo/CONVERSION.testGroup Line: 827 Failed: assertSame Expected: [[nan], identityHash="100785925"] Actual: [[-infinity], identityHash="112493565"] I think it is a difference in the C++ libraries on AIX, maybe coming from here in StringClass.cpp: // non numeric, so this could be one of the special cases if (strCompare("nan")) { result = std::numeric_limits<double>::signaling_NaN(); return true; } But, I'm not sure. Plus, I don't really know what to do about it even if it is the root cause. <grin> I'll attach the log output. ---------------------------------------------------------------------- Comment By: Rainer Tammer (tammer) Date: 2008-10-30 15:22 Message: Hello, ok here is the thing: With the following test: #include <stdio.h> #include <math.h> #include <limits> int main(void) { /* double number = NAN; */ double number = std::numeric_limits<double>::signaling_NaN(); if (isnan(number)) { printf(">0\n"); } else if (number == +HUGE_VAL) { printf("+HUGE_VAL\n"); } else if (number == -HUGE_VAL) { printf("-HUGE_VAL\n"); } else { printf("none\n"); } return(0); } I get the following results: Linux SLES9 / 32 Bit ./test >0 AIX 5.3 32 bit compile on 64 bit OS: ./test -HUGE_VAL Bye Rainer ---------------------------------------------------------------------- Comment By: Rainer Tammer (tammer) Date: 2008-10-30 15:15 Message: Hello, I am not good the the C++ stuff ... but here is another example: #include <stdio.h> #include <math.h> #include <limits> int main(void) { /* double number = NAN; */ double number = std::numeric_limits<double>::signaling_NaN(); printf("number=%lld\n", number); // make a nan value a string value if (isnan(number)) { printf(">0\n"); } else if (number == -HUGE_VAL) { printf("HUGE_VAL"); } else { printf("no\n"); } return(0); } ./test_isnan number=-4503599627370496 HUGE_VAL Bye Rainer ---------------------------------------------------------------------- Comment By: Rainer Tammer (tammer) Date: 2008-10-30 15:01 Message: Hello, on Linux (SLES9 / 32 bit): ./test number=1074642088 >0 Bye Rainer ---------------------------------------------------------------------- Comment By: Rick McGuire (bigrixx) Date: 2008-10-30 15:00 Message: I'm not sure I understand what you mean by "where is nan defined ??". In that context, "nan" is just the character string "nan". The ObjectToDouble() code recognizes that value as special and returns the value "std::numeric_limits<double>::signaling_NaN()" as a result. This is part of the standard C++ standard library. That's the value you need to be using in your test program. ---------------------------------------------------------------------- Comment By: Rainer Tammer (tammer) Date: 2008-10-30 14:54 Message: Hello, in the test you use val = "nan". where is nan defined ?? this is a little test: #include <stdio.h> #include <math.h> int main(void) { double number = NAN; /* NAN comes from math.h */ printf("number=%ld\n"); .... // make a nan value a string value if (isnan(number)) { printf(">0\n"); } else if (number == +HUGE_VAL) { printf("+infinity\n"); } else if (number == -HUGE_VAL) { printf("-infinity\n"); } return(0); } ./test_isnan number=804399748 >0 Bye Rainer ---------------------------------------------------------------------- Comment By: Rick McGuire (bigrixx) Date: 2008-10-29 17:56 Message: I see two potential places where things can go wrong, but this most likely is due to a problem in the C++ libraries. The first place is where you noted. It's possible that std::numeric_limits<double>::signaling_NaN() is not actually returning a NaN value. The other place is in NumberString::newInstanceFromDouble() where the double object is converted back into a Rexx object. It is possible that the test for isnan() is failing, but given that an "==" comparison is always supposed to fail for a NaN value, the comparison to -HUGE_VAL should not work. The other possibility is it made it through all of the if special cases and sprintf() formatted the value as "-infinity" for us. Understanding where the "-infinity" string comes from would help narrow down the real point of failure. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=684730&aid=2207721&group_id=119701 |