From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4763 invoked by alias); 5 Jun 2018 12:52:25 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: List-Unsubscribe: X-Seq: 23438 Received: (qmail 23561 invoked by uid 1010); 5 Jun 2018 12:52:25 -0000 X-Qmail-Scanner-Diagnostics: from 195.159.176.226 by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(195.159.176.226):SA:0(-0.6/5.0):. Processed in 2.638895 secs); 05 Jun 2018 12:52:25 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-0.6 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RDNS_NONE autolearn=no autolearn_force=no version=3.4.1 X-Envelope-From: gcszu-zsh-users@m.gmane.org X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | X-Injected-Via-Gmane: http://gmane.org/ Mail-Followup-To: zsh-users@zsh.org To: zsh-users@zsh.org From: Emanuel Berg Subject: Re: 1.75 -> 1-3/4 Date: Tue, 05 Jun 2018 14:52:10 +0200 Message-ID: <86r2ll4cqt.fsf@zoho.com> References: <8636y25hm7.fsf@zoho.com> <2671261528169177@web23g.yandex.ru> Mime-Version: 1.0 Content-Type: text/plain X-Complaints-To: usenet@blaine.gmane.org User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) Mail-Copies-To: never Cancel-Lock: sha1:1xXJe2IfKJ/gTVqtLm4MSU1vcMw= Artur Penttinen wrote: >> [1] http://user.it.uu.se/~embe8573/conf/.zsh/math > > # ths 2 > ths:8: maximum nested function level reached; increase FUNCNEST? Terve/priviet, nice catch, here's an update: ths () { local value=$1 local denom=${2:-16} local whole=$(( int(floor($value)) )) local rest=$(( $value - $whole )) local frac=$(( int(rint($rest * $denom)) )) if (( $frac > 0 && $(( $frac % 2 )) == 0 )); then local new_denom=$(( denom / 2 )) ths $value $new_denom else local frace (( $frac > 0 )) && frace=-${frac}/${denom} echo ${whole}${frace} fi } # $ ths 2.0 # 2 # $ ths 1.75 # 1-3/4 -- underground experts united http://user.it.uu.se/~embe8573