From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14076 invoked by alias); 14 May 2015 09:07:53 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 35121 Received: (qmail 14142 invoked from network); 14 May 2015 09:07:47 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS autolearn=ham version=3.3.2 X-Injected-Via-Gmane: http://gmane.org/ Mail-Followup-To: zsh-workers@zsh.org To: zsh-workers@zsh.org From: Emanuel Berg Subject: Re: why do ceil/floor give the decimal dot? Date: Thu, 14 May 2015 11:12:51 +0200 Message-ID: <87oalncyjw.fsf@debian.uxu> References: <87oalodmns.fsf@debian.uxu> <150513195617.ZM29493@torch.brasslantern.com> <87d223et0a.fsf@debian.uxu> <150513210405.ZM29616@torch.brasslantern.com> Mime-Version: 1.0 Content-Type: text/plain X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: nl106-137-66.student.uu.se Mail-Copies-To: never User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) Cancel-Lock: sha1:3S9lGF56Uz94GMmpzGbcpTzH0dA= Bart Schaefer writes: > If what you want to argue is that floating point > values that happen to be whole numbers should not > print the trailing dot, that's another discussion. You mean like this? $ printf "%d\n" $(( 7.5 + 0.5 )) 8 No, I don't care what data type is used as long as 1. ceil and floor return integers in the math sense (otherwise the function I just posted is is incorrect); and 2. when the result is printed, it is printed as x (and not "x.") for an integer x, because otherwise I can't use that function in scripts and functions without removing the dot each time. Or, do you think the "unbroken chain of floats"/"the shell will deal with it"-approach instead should be put to use, i.e. rolling with the punches, e.g. $ g () { return 6.0 }; g; b=$?; printf "%d\n" $b 6 Is that what you are saying? -- underground experts united http://user.it.uu.se/~embe8573