From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25849 invoked by alias); 14 May 2015 03:24:37 -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: 35118 Received: (qmail 20777 invoked from network); 14 May 2015 03:24:34 -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 05:29:41 +0200 Message-ID: <87d223et0a.fsf@debian.uxu> References: <87oalodmns.fsf@debian.uxu> <150513195617.ZM29493@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:nh8pjZxqukChk38Mqhqt75OdAPo= Bart Schaefer writes: > It's not an oversight. The doc says: > > Most functions take floating point arguments and > return a floating point value. However, any > necessary conversions from or to integer type will > be performed automatically by the shell. Apart from > atan with a second argument and the abs, int and > float functions, all functions behave as noted in > the manual page for the corresponding C function > [...] > > So ciel and floor return float precisely and > intentionally because the C functions do so. Take a look at this [1] zsh: prefix-len () { local hosts=$1 echo $(( 32 - int(ceil(log($hosts)/log(2))) )) } without the integer conversion, the output for prefix-len 30 isn't 27, but "27." [1] http://user.it.uu.se/~embe8573/conf/.zsh/web -- underground experts united http://user.it.uu.se/~embe8573