From owner-freebsd-mips@freebsd.org Mon Nov 13 22:52:34 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 7CF56DD96A0 for ; Mon, 13 Nov 2017 22:52:34 +0000 (UTC) (envelope-from kg365@hermes.cam.ac.uk) Received: from ppsw-42.csi.cam.ac.uk (ppsw-42.csi.cam.ac.uk [131.111.8.142]) (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 3F13F22C1 for ; Mon, 13 Nov 2017 22:52:33 +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-f176.google.com ([209.85.220.176]:49011) by ppsw-42.csi.cam.ac.uk (smtp.hermes.cam.ac.uk [131.111.8.158]:587) with esmtpsa (PLAIN:kg365) (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) id 1eENah-000M1N-84 (Exim 4.89) for freebsd-mips@freebsd.org (return-path ); Mon, 13 Nov 2017 22:52:31 +0000 Received: by mail-qk0-f176.google.com with SMTP id a142so21852121qkb.5 for ; Mon, 13 Nov 2017 14:52:31 -0800 (PST) X-Gm-Message-State: AJaThX45DI94biiITJQBKG9RHhZjhnJd2XlsXooJ+wFOe/tB2XhB3ELT VqAtZhQiLYmr1FEjxqHuoPlK/YIqxDT9SZoMFHU= X-Google-Smtp-Source: AGs4zMYqT3pJGFv1c5hFB4djRqfIXP8q9K+47oXa56yqw5Jvcon3FxFVKSw6yIXaSEpbjcpfAfaTFKYoEVffrAz5qCo= X-Received: by 10.55.221.212 with SMTP id u81mr16367392qku.174.1510613550671; Mon, 13 Nov 2017 14:52:30 -0800 (PST) MIME-Version: 1.0 Received: by 10.12.153.1 with HTTP; Mon, 13 Nov 2017 14:52:10 -0800 (PST) From: Khilan Gudka Date: Mon, 13 Nov 2017 22:52:10 +0000 X-Gmail-Original-Message-ID: Message-ID: Subject: fabs(-0.0) returns -0.0 To: freebsd-mips@freebsd.org 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: Mon, 13 Nov 2017 22:52:34 -0000 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. Thanks, Khilan