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.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 7804 invoked from network); 26 Mar 2021 00:16:41 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 26 Mar 2021 00:16:41 -0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20200801; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Message-ID:Date: Content-Transfer-Encoding:Content-ID:Content-Type:MIME-Version:Subject:To: References:From:In-reply-to:cc:Reply-To:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=/nWBVawGFGH98/Wbn5l45kFikr79gl6SFZYXq5jsDEw=; b=HnnH+pZI0OztebxDFKrPEfC0ON 318rKoXYoZ68JCd4xHfbMBoN2030QZen/F3M1fO25VZl4xNT8wmPNIhUcQywIhFf0Nbcw6qmea2AD L/bqOcp5lWRW2tKqMWEVor5clpOzf7RvIAr8/4PCn26n2rQYx8T9qqCJtNKX9/SgZ2YICLu3wdB7j xhbMWw8/aRAZza2yGQcffFwhkYrEt83MvHwVxEDV8QFlBIgmAd4idTTkurlnn50USsN2Lq4yonlEM uhS0rUCnggVUVMU7CdIvtpxTrsikTAUfanXWM9D0sofx3dj+YwA52T0Uy3tSzPSmLwO8yVJfstgyo MwLBIpCw==; Received: from authenticated user by zero.zsh.org with local id 1lPa9V-000Gzn-9i; Fri, 26 Mar 2021 00:16:37 +0000 Received: from authenticated user by zero.zsh.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1lPa8w-000GTT-3H; Fri, 26 Mar 2021 00:16:02 +0000 Received: from [192.168.178.21] (helo=hydra) by mail.kiddle.eu with esmtp(Exim 4.93.0.4) (envelope-from ) id 1lPa8u-000Nke-9O; Fri, 26 Mar 2021 01:16:01 +0100 cc: Zsh Users In-reply-to: <0227b30d-4f09-2c8b-1248-557859d875ce@eastlink.ca> From: Oliver Kiddle References: <0227b30d-4f09-2c8b-1248-557859d875ce@eastlink.ca> To: Ray Andrews Subject: Re: arithmetic anomaly MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <91302.1616717760.1@hydra> Content-Transfer-Encoding: 8bit Date: Fri, 26 Mar 2021 01:16:00 +0100 Message-ID: <91303-1616717760.288585@Iyj2.F9RA.VD0P> X-Seq: 26606 Archived-At: X-Loop: zsh-users@zsh.org Errors-To: zsh-users-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-users-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: Archived-At: Ray Andrews wrote: >     printf "%.0f / %.0f \n" "$(( numerator ))" "$(( denominator ))" Where you use %f, %d etc. the printf parameters are evaluated in math context so there's no need to convert via ASCII decimal representation with "$(( … ))". You can just do: printf "%.0f / %.0f \n" numerator denominator or even printf "%.0f / %.0f \n" numerator 'level**level' That feature is particular to zsh's printf. It doesn't really get you much further with this particular script. Arbitrary precision (bignums) might have been appropriate in the case of the shell rather than floats but floats are what we have. Oliver