From owner-freebsd-mips@freebsd.org Tue Nov 21 15:14:09 2017 Return-Path: Delivered-To: freebsd-mips@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EC3AEDF1391 for ; Tue, 21 Nov 2017 15:14:09 +0000 (UTC) (envelope-from kg365@hermes.cam.ac.uk) Received: from ppsw-33.csi.cam.ac.uk (ppsw-33.csi.cam.ac.uk [131.111.8.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B0AB67229B; Tue, 21 Nov 2017 15:14:08 +0000 (UTC) (envelope-from kg365@hermes.cam.ac.uk) X-Cam-AntiVirus: no malware found X-Cam-ScannerInfo: http://help.uis.cam.ac.uk/email-scanner-virus Received: from mail-qk0-f175.google.com ([209.85.220.175]:35359) by ppsw-33.csi.cam.ac.uk (smtp.hermes.cam.ac.uk [131.111.8.157]:587) with esmtpsa (PLAIN:kg365) (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) id 1eHAFS-000qNI-gi (Exim 4.89) (return-path ); Tue, 21 Nov 2017 15:14:06 +0000 Received: by mail-qk0-f175.google.com with SMTP id p19so12459112qke.2; Tue, 21 Nov 2017 07:14:06 -0800 (PST) X-Gm-Message-State: AJaThX7DFtDfcKSynOx0uPVem9XrTV4uu2E43HHL8b2MSLbHB+ZDolEA Za0bztIGNlqWl+4O9Itm+mxH97F3DWzTjlf/LtU= X-Google-Smtp-Source: AGs4zMa7Eb9LIu4eypWTiT6aSsW3DVz6bdVa2eIW7jVNr5foowymET6hFzU0klYyL8+w10EuI/ueeGs14yqAEnQ+1bY= X-Received: by 10.55.8.4 with SMTP id 4mr7228238qki.249.1511277245384; Tue, 21 Nov 2017 07:14:05 -0800 (PST) MIME-Version: 1.0 Received: by 10.12.153.1 with HTTP; Tue, 21 Nov 2017 07:13:44 -0800 (PST) In-Reply-To: <2687660.XtxPXlZaqn@ralph.baldwin.cx> References: <2687660.XtxPXlZaqn@ralph.baldwin.cx> From: Khilan Gudka Date: Tue, 21 Nov 2017 15:13:44 +0000 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: fabs(-0.0) returns -0.0 To: John Baldwin Cc: freebsd-mips@freebsd.org, Khilan Gudka Sender: Khilan Gudka Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.25 X-BeenThere: freebsd-mips@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: Porting FreeBSD to MIPS List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 Nov 2017 15:14:10 -0000 Alex Richardson has submitted a patch to fix fabs() on FreeBSD: https://reviews.freebsd.org/D13135 Thanks, Khilan On 14 November 2017 at 01:43, John Baldwin wrote: > On Monday, November 13, 2017 10:52:10 PM Khilan Gudka wrote: > > Hi, > > > > The implementation of fabs(3) for MIPS (at least) appears to not be > giving > > the right answer for when -0 is passed, as it returns -0 instead of +0. > The > > implementation of fabs is: > > > > double fabs(double x) { > > if (x < 0) > > return -x; > > return x; > > } > > > > The if-test fails for -0 and thus it is returned. Is this a known issue? > A > > simple fix would be to return x+0.0 instead of just x. > > > > The implication of this is that other functions which rely on fabs, such > as > > hypot, also return -0. For example, hypot(-0.0, 0.0) returns -0 instead > of > > +0. > > The C version of fabs() for 32-bit arm has the same misimplementation btw. > All other architectures implement fabs in assembly in libc. > > -- > John Baldwin >