X-Authentication-Warning: delorie.com: mail set sender to djgpp-workers-bounces using -f X-Recipient: djgpp-workers AT delorie DOT com X-Authenticated: #27081556 X-Provags-ID: V01U2FsdGVkX1+MFiVjR5WMUgx6lhuvEB5OViPmn8fdfUcDWE2TUf ObnxqusVVI10zb Message-ID: <513900D2.6040106@gmx.de> Date: Thu, 07 Mar 2013 22:04:18 +0100 From: Juan Manuel Guerrero User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121025 Thunderbird/16.0.2 MIME-Version: 1.0 To: Eli Zaretskii CC: djgpp-workers AT delorie DOT com Subject: Re: Printing sign of NaN. References: <51364BCD DOT 1030807 AT gmx DOT de> <83y5e11pn7 DOT fsf AT gnu DOT org> <5137961A DOT 4000505 AT gmx DOT de> <83mwug1bnn DOT fsf AT gnu DOT org> In-Reply-To: <83mwug1bnn.fsf@gnu.org> Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-Y-GMX-Trusted: 0 Reply-To: djgpp-workers AT delorie DOT com Am 06.03.2013 22:06, schrieb Eli Zaretskii: >> Date: Wed, 06 Mar 2013 20:16:42 +0100 >> From: Juan Manuel Guerrero >> CC: Eli Zaretskii >> >> > Isn't NaN always negative? Do you succeed in printing both negative >> > and positive NaN with this patch? >> >> Yes, I can print both signs with this change. > And what about reading a signed NaN? Does it produce a value of that > same sign when printed afterwards? > Sorry but I do not fully understand what exactly I shall test. I have run the code snippet below on linux and using djgpp. I think when the additions are passed as arguments to printf the "signed " NaN is read. Both give the same result like below: NaN + NaN = -nan NaN + NaN = -nan NaN + v = -nan NaN + NaN = +nan NaN + NaN = nan NaN + v = nan Regards, Juan M. Guerrero #include typedef struct { unsigned mantissal:32; unsigned mantissah:32; unsigned exponent:15; unsigned sign:1; } long_double_t; typedef union { long double ld; long_double_t ldt; } _longdouble_union_t; int main(void) { long double v = 1.2345; _longdouble_union_t nan; nan.ldt.mantissal = 0x00000001U; nan.ldt.mantissah = 0xC0000000U; nan.ldt.exponent = 0x7FFFU; nan.ldt.sign = 1; printf("NaN + NaN = %+Lg NaN + NaN = %-Lg NaN + v = %Lg\n", nan.ld + nan.ld, nan.ld + nan.ld, nan.ld + v); nan.ldt.sign = 0; printf("NaN + NaN = %+Lg NaN + NaN = %-Lg NaN + v = %Lg\n", nan.ld + nan.ld, nan.ld + nan.ld, nan.ld + v); return 0; }