From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 3469 invoked from network); 23 Mar 2022 16:37:02 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 23 Mar 2022 16:37:02 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1648053422; b=jrFTmuQyRBkcGNbtzzXJHYIIJhHxBhZ5kjCq/nE4OKXlRqtdPKpye+4aqBM1DVrhSlvdC3bnSn vUjMahxFAaTtIiGU1AmplZPM9AFL3LrDSBrz0n09wYowL+GR9Lcqp0nOGVSh9D/iBNZYYEtwCg BDZLvA19K6ItxowE140teA0aGUJZX5Im1GLIyNk+oPFw3x+m0eyz0zNuyEbTiphKrKM2rkI/Pb AqJNrBRfqgLMvEw79lYnvmM4S+RNbt9ivU1PofS1O9mdWWRDXCmN9owL94cpD6c13ShR2kvKFZ lirBAaOtnQRLhwdpcJTmtFlAMYhmEWoq5NMKrFMlE7mc7A==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (cventin.lip.ens-lyon.fr) smtp.remote-ip=140.77.13.17; dmarc=none header.from=vinc17.net; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1648053422; bh=Wuek3u4u+KDEb9++5ReMiPINEF3AkQ824KHwduuf4XY=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:MIME-Version: Message-ID:Subject:To:From:Date:DKIM-Signature; b=pAqGkz9r8qqH97H/rSvwwghvqsO+PHyE0NqKAheLt/9gdn4nv6aowHeRBGEazf6B3y3eLli7j2 1FemyjUZj6DwYu8q1cl9tWFC0GNwQ02ZIzTsjb4QEJ/fZ/RjwRfcE9XZa0UvBEHGiWzJmnVW3H QcC2ln3dqIvtZS/hXre05/CgdVXNLfixB5C1gxPh3GIlDf2lmW2A6aen198V3AFRwdPKj7a9ax 7kfIUfVnoLAFVLwYMN+mx/A3iq8tk7W27LVy87pkgQC11typdCi6F3XPC4xKk1PjHpV/sNWiH8 ZbVIjJZAjR0Dk28lH7T2x5mN8rsZDDCvgPFdJLk5Ey+pXg==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:Message-ID:Subject:To:From:Date:Reply-To:Cc: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References; bh=94v5t2kT4rb8qnYIFplBOZX2NLH7/iVX6+qT0jXvPco=; b=h5HyrzseHXYcjf0dR4qkKgvXt2 qiVQg4I5aPE29K/eaaSJ+uoqlZFLtpIdFvW/Qow2sYwwZvy53A5cGWqyDSkplzaeYhZXIn4905KCQ 5S6FjWY4edSJzq5vRHi52nEVV32c1LXYmA5LP+tSnuzmC1wKuKMmwz3BJuNvxbWcdo3IOE3dJsFAJ 6SPpOQfNJ6kgcXcwbeckv6ZlMEnzXmoXfPy97L1kGdZ58VSae3+XW5RdYN8adibXJwr5z/qZtXY6v LqFhot4rmMRpXYwGQk5xIaUOAg+BKUdRqOjX1u7Oc7/9fgtlGrG7I9Aw1DGzEeLD+zgZSNSRruOql 5as7Zmog==; Received: from authenticated user by zero.zsh.org with local id 1nX3yo-000F4O-Fb; Wed, 23 Mar 2022 16:37:02 +0000 Authentication-Results: zsh.org; iprev=pass (cventin.lip.ens-lyon.fr) smtp.remote-ip=140.77.13.17; dmarc=none header.from=vinc17.net; arc=none Received: from cventin.lip.ens-lyon.fr ([140.77.13.17]:36602) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1nX3yY-000EjH-G9; Wed, 23 Mar 2022 16:36:48 +0000 Received: from vlefevre by cventin.lip.ens-lyon.fr with local (Exim 4.95) (envelope-from ) id 1nX3yY-004zxj-5i; Wed, 23 Mar 2022 17:36:46 +0100 Date: Wed, 23 Mar 2022 17:36:46 +0100 From: Vincent Lefevre To: zsh-workers@zsh.org Subject: floating-point precision and zsh vs ksh93 and coreutils Message-ID: <20220323163646.GB1190496@cventin.lip.ens-lyon.fr> Mail-Followup-To: zsh-workers@zsh.org MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit X-Mailer-Info: https://www.vinc17.net/mutt/ User-Agent: Mutt/2.2.1+12 (1ba319cf) vl-138565 (2022-03-05) X-Seq: 49886 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: For floating-point arithmetic evaluation, it appears that zsh uses the "double" type while ksh93 and GNU coreutils both use the "long double" type, which means incompatibility: $ ksh93 -c '/usr/bin/printf "%a\n" $((1./3))' 0xa.aaaaaaaaaaaaa9ep-5 $ zsh -fc '/usr/bin/printf "%a\n" $((1./3))' 0xa.aaaaaaaaaaaa74ep-5 and $ ksh93 -c '/usr/bin/printf "%a\n" $((43./2**22))' 0xa.cp-20 $ zsh -fc '/usr/bin/printf "%a\n" $((43./2**22))' 0xa.c0000000000025cp-20 In the second case, while the number is exactly representable (and has the same value) in both double and long double, the issue is visible because the number is passed with a decimal representation, with enough decimal digits to read the result with 53-bit precision in the zsh test. Shouldn't zsh switch to long double? Note: using printf from the GNU coreutils instead of the zsh printf builtin is needed for %a support. -- Vincent Lefèvre - Web: 100% accessible validated (X)HTML - Blog: Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)