www.delorie.com/archives/browse.cgi | search |
X-Recipient: | archive-cygwin AT delorie DOT com |
X-SWARE-Spam-Status: | No, hits=-4.4 required=5.0 tests=AWL,BAYES_00 |
X-Spam-Check-By: | sourceware.org |
From: | "Phan, Linh H (343H)" <linh DOT h DOT phan AT jpl DOT nasa DOT gov> |
To: | "cygwin AT cygwin DOT com" <cygwin AT cygwin DOT com> |
Date: | Sat, 19 Dec 2009 22:44:43 -0800 |
Subject: | wrap around problem for "double"? |
Message-ID: | <79D001DEDB0DEC47A247B110F3E8668206E59D5F92@ALTPHYEMBEVSP30.RES.AD.JPL> |
MIME-Version: | 1.0 |
X-Source-Sender: | linh DOT h DOT phan AT jpl DOT nasa DOT gov |
X-AUTH: | Authorized |
Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
List-Id: | <cygwin.cygwin.com> |
List-Subscribe: | <mailto:cygwin-subscribe AT cygwin DOT com> |
List-Archive: | <http://sourceware.org/ml/cygwin/> |
List-Post: | <mailto:cygwin AT cygwin DOT com> |
List-Help: | <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs> |
Sender: | cygwin-owner AT cygwin DOT com |
Mail-Followup-To: | cygwin AT cygwin DOT com |
Delivered-To: | mailing list cygwin AT cygwin DOT com |
Hi, I was wondering why when "double" is assigned into a "short int" in cygwi= n 1.7, it doesn't wrap around correctly, eg: main ()=20 { short int x; int y =3D -63757; double y2 =3D -63757; x =3D y; // wraps around correctly going from int to short int printf("%d (should be 1779)\n",x); x =3D y2; // but just truncates when going from double to short int printf("%d (THIS DOES NOT WRAP AROUND CORRECTLY, should be 1779)\n",x); } The output is this: 1779 (should be 1779) -32768 (THIS DOES NOT WRAP AROUND CORRECTLY, should be 1779) Instead of wrapping around for the short int, it just truncates it at -3276= 8 which is not the behavior I was expecting. It doesn't work like this eit= her on linux or solaris operating system. Also, when assigning a double in= to an int, it will just truncates and not wrap around. Is this a bug and i= f so, is there a newer version of Cygwin that fixes this bug? -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |