From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27574 invoked by alias); 14 Dec 2007 23:21:03 -0000 Received: (qmail 27541 invoked by uid 48); 14 Dec 2007 23:20:52 -0000 Date: Fri, 14 Dec 2007 23:21:00 -0000 Subject: [Bug c/34473] New: casting negative __int128_t to float/double rounds to nearest multiple of 2048 X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "james at albanarts dot com" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2007-12/txt/msg01348.txt.bz2 casting a negative _int128_t value to a float or double rounds the resulting floating point number to the nearest multiple of 2048. the following C program demonstrates which I compiled with the compile string "gcc": int main() { __int128_t x = -1025; double f = x; return f < -1500.0; } I would expect the exit code of the program to be 0. f should get set to -1025.0, which is not < -1500.0. However when I compile and run this the exit code is 1. Further examination shows that f gets the following values: 0.0 for x in the range -1024 to 0 -2048.0 for x in the range -3060 to -1025 ...etc... When x is positive f gets set to the expected (the same) value. "gcc -v" output: Using built-in specs. Target: x86_64-redhat-linux Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --enable-plugin --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --with-cpu=generic --host=x86_64-redhat-linux Thread model: posix gcc version 4.1.2 20070925 (Red Hat 4.1.2-33) -- Summary: casting negative __int128_t to float/double rounds to nearest multiple of 2048 Product: gcc Version: 4.1.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: james at albanarts dot com GCC build triplet: x86_64-redhat-linux GCC host triplet: x86_64-redhat-linux GCC target triplet: x86_64-redhat-linux http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34473