From owner-freebsd-bugs@FreeBSD.ORG Wed Feb 28 18:10:04 2007 Return-Path: X-Original-To: freebsd-bugs@hub.freebsd.org Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 1508816A409 for ; Wed, 28 Feb 2007 18:10:04 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [69.147.83.40]) by mx1.freebsd.org (Postfix) with ESMTP id D158513C4A5 for ; Wed, 28 Feb 2007 18:10:03 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.4/8.13.4) with ESMTP id l1SIA3SZ035401 for ; Wed, 28 Feb 2007 18:10:03 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.4/8.13.4/Submit) id l1SIA3Mm035400; Wed, 28 Feb 2007 18:10:03 GMT (envelope-from gnats) Resent-Date: Wed, 28 Feb 2007 18:10:03 GMT Resent-Message-Id: <200702281810.l1SIA3Mm035400@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Denis Koreshkov Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 4A2DE16A407 for ; Wed, 28 Feb 2007 18:02:05 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [69.147.83.33]) by mx1.freebsd.org (Postfix) with ESMTP id 2C72213C4A5 for ; Wed, 28 Feb 2007 18:02:05 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.13.1/8.13.1) with ESMTP id l1SI247A005333 for ; Wed, 28 Feb 2007 18:02:04 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.13.1/8.13.1/Submit) id l1SI24Cb005332; Wed, 28 Feb 2007 18:02:04 GMT (envelope-from nobody) Message-Id: <200702281802.l1SI24Cb005332@www.freebsd.org> Date: Wed, 28 Feb 2007 18:02:04 GMT From: Denis Koreshkov To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.0 Cc: Subject: bin/109692: printing -NaN X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Feb 2007 18:10:04 -0000 >Number: 109692 >Category: bin >Synopsis: printing -NaN >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Wed Feb 28 18:10:03 GMT 2007 >Closed-Date: >Last-Modified: >Originator: Denis Koreshkov >Release: freebsd 6.2-stable >Organization: BMSTU >Environment: >Description: The vfprintf() function correctly formats +Inf and -Inf but it has no provision for distinguishing between +NaN and -NaN. Hence all functions of printf(3) family output all -NaNs as NaNs. >How-To-Repeat: printf("%g %g\n", +0.0/0.0, -0.0/0.0); outputs: NaN NaN which should be: NaN -NaN >Fix: vfprintf(3) tests for a 'double' argument being an Inf or a NaN using isinf() and isinf(). Then, an Inf's signum is detected by a trivial arithmetic comparison to 0.0 But arithmetic comparisons fail when an argument is a NaN, so there is no corresponding code to set a negative NaN's signum to '-'. Consider using copysign(1.0, _double) which returns +1.0 and -1.0 for +NaN and -NaN. This is the case for the msun libm used in FreeBSD, though other implementations of copysign(3) may not derive a NaN's signum correctly, or raise an exception with signaling NaNs. >Release-Note: >Audit-Trail: >Unformatted: