From owner-freebsd-numerics@freebsd.org Thu May 9 17:12:37 2019 Return-Path: Delivered-To: freebsd-numerics@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 73AC41588720 for ; Thu, 9 May 2019 17:12:37 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mailman.ysv.freebsd.org (mailman.ysv.freebsd.org [IPv6:2001:1900:2254:206a::50:5]) by mx1.freebsd.org (Postfix) with ESMTP id 0EB2470EBA for ; Thu, 9 May 2019 17:12:37 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: by mailman.ysv.freebsd.org (Postfix) id C701C158871E; Thu, 9 May 2019 17:12:36 +0000 (UTC) Delivered-To: numerics@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B54D1158871D for ; Thu, 9 May 2019 17:12:36 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.ysv.freebsd.org (mxrelay.ysv.freebsd.org [IPv6:2001:1900:2254:206a::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.ysv.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 5188570EB7 for ; Thu, 9 May 2019 17:12:36 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2001:1900:2254:206a::16:76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.ysv.freebsd.org (Postfix) with ESMTPS id 8F5BD16A67 for ; Thu, 9 May 2019 17:12:35 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.118]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id x49HCZCX044070 for ; Thu, 9 May 2019 17:12:35 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id x49HCZZq044069 for numerics@FreeBSD.org; Thu, 9 May 2019 17:12:35 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: numerics@FreeBSD.org Subject: [Bug 237800] pow(3) returns inaccurate results Date: Thu, 09 May 2019 17:12:35 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: misc X-Bugzilla-Version: CURRENT X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Many People X-Bugzilla-Who: khw@cpan.org X-Bugzilla-Status: Open X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: numerics@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: freebsd-numerics@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Discussions of high quality implementation of libm functions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 09 May 2019 17:12:37 -0000 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D237800 --- Comment #7 from Karl Williamson --- (In reply to Peter Jeremy from comment #3) There's nothing in the ticket that indicates perl is using pow() to convert between strings and floating point values. To do that, it instead uses a c= all to a C library function: some strtod() flavor, which particular one depends= on the desired precision, and what is available on the platform, determined by configuration options at the time the perl executable is compiled. If those options indicate to use long doubles, it will use strtodl(), for example. However, it used to be that perl used atof() in some circumstances instead = of when it otherwise could use plain strtod(). Perl does use pow() when performing an exponentiation operation and regular doubles were requested at perl compilation time. This module does exponentiation. The maintainer of the module discovered that the results of that operation were sometimes wrong, and further somehow figured out that if the floating point value was stringified and then reparsed by perl, that the value magically was corrected. Statements s/he wrote in the perl language expand to do a C library sprintf and then an atof on that result. Except t= hat now it's sprintf followed by strtod. But it turns out that the magic was only because of the poorer precision offered by atof(), and when perl converted to not ever use atof, the workar= ound failed. --=20 You are receiving this mail because: You are the assignee for the bug.=