From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12107 invoked by alias); 14 May 2015 04:02: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: 35119 Received: (qmail 228 invoked from network); 14 May 2015 04:02:51 -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.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=larryv.me; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-sasl-enc :x-sasl-enc; s=mesmtp; bh=qjkuVouGibV3XTfhwKOEXbhexD4=; b=O31Ja6 mK8IZQD5HsavAvO/Xb8WZp12IPtVYd3caDXEVLSmC0i8E9lcljsDDcZFbYftP6Cz 6q/BUJgre9gqHnTDb9EZAVqAJqV6fwV740NtlHkS3Bl7o+nwBxVbIb/BUEgvseNJ pStnIpuQJzRiR6ZDMRZNPWkqj8E5swx7BQz0E= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=qjkuVouGibV3XTf hwKOEXbhexD4=; b=JzyHvQ/cS9gT0rcaKGG7KKetS+YE9UvQ2Tmxj3hzI4UJHCA Cjng9qcmKJW0fa0rjEHPtty++3CN0C1ZRXKw1lf1gL4GfPeRWaGPP3pGNQJ9aFw9 E7nNNNIHYzPyCs3v44BoG7tGVXQTlC1AWY8zEJ5gPDH2leyjVQj0Ck+iY/pI= X-Sasl-enc: woH3VtNPblf1YlS95DAgYH7ZPPtj1AUHMNnbdI3JnOIJ 1431575633 Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2098\)) Subject: Re: why do ceil/floor give the decimal dot? From: =?utf-8?Q?Lawrence_Vel=C3=A1zquez?= In-Reply-To: <87d223et0a.fsf@debian.uxu> Date: Wed, 13 May 2015 23:53:53 -0400 Cc: zsh-workers@zsh.org Content-Transfer-Encoding: 7bit Message-Id: References: <87oalodmns.fsf@debian.uxu> <150513195617.ZM29493@torch.brasslantern.com> <87d223et0a.fsf@debian.uxu> To: Emanuel Berg X-Mailer: Apple Mail (2.2098) On May 13, 2015, at 11:29 PM, Emanuel Berg wrote: > 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." Yes, this is expected and correct. From "ARITHMETIC EVALUATION" in the zshmisc(1) man page: Promotion of integer to floating point values is performed where necessary. So: - "ceil(log(30)/log(2))" returns floating-point "5." - integer "32" is promoted to floating point "32." - floating point "32." - floating point "5." = floating-point "27." vq