From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8963 invoked by alias); 19 Apr 2008 00:08:24 -0000 Received: (qmail 14171 invoked by uid 48); 18 Apr 2008 22:04:01 -0000 Date: Sat, 19 Apr 2008 00:08:00 -0000 Message-ID: <20080418220401.14170.qmail@sourceware.org> From: "sjmunroe at us dot ibm dot com" To: glibc-bugs@sources.redhat.com In-Reply-To: <20070919134419.5044.vincent+libc@vinc17.org> References: <20070919134419.5044.vincent+libc@vinc17.org> Reply-To: sourceware-bugzilla@sourceware.org Subject: [Bug libc/5044] printf doesn't take the rounding mode into account X-Bugzilla-Reason: CC Mailing-List: contact glibc-bugs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: glibc-bugs-owner@sourceware.org X-SW-Source: 2008-04/txt/msg00129.txt.bz2 ------- Additional Comments From sjmunroe at us dot ibm dot com 2008-04-18 22:03 ------- the core problem is that you are trying to apply decimal rounding rules to IEEE754 Binary float. For example 0.5001 is really 0x1.000d1b71758e20p-1 (format %.14a which shows the mantisa in hex). Note that there is no exact binary representation for rounding value 0.005 implied by this request. To get what Vincent says he wants would require converting the IEEE754 double to decimal and perform the rounding in decimal (via quantize). It is is not clear that The ISO C standard says in 7.19.6.1#13 requires this: "Otherwise, the source value is bounded by two adjacent decimal strings L < U, both having DECIMAL_DIG significant digits; the value of the resultant decimal string D should satisfy L <= D <= U, with the extra stipulation that the error should have a correct sign for the current rounding direction." This implies that either L or U (.50 or .51) are allowed! -- http://sourceware.org/bugzilla/show_bug.cgi?id=5044 ------- You are receiving this mail because: ------- You are on the CC list for the bug, or are watching someone who is.