From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Marko Vojinovic Newsgroups: gmane.emacs.help Subject: Re: 1.75 -> 1-3/4 Date: Tue, 5 Jun 2018 17:25:26 +0200 Message-ID: <20180605172526.78adefab@Yoda> References: <86lgbt4cb6.fsf@zoho.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Trace: blaine.gmane.org 1528215203 9908 195.159.176.226 (5 Jun 2018 16:13:23 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 5 Jun 2018 16:13:23 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Jun 05 18:13:19 2018 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fQEaC-0002RH-81 for geh-help-gnu-emacs@m.gmane.org; Tue, 05 Jun 2018 18:13:16 +0200 Original-Received: from localhost ([::1]:47898 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQEcJ-0006N0-AF for geh-help-gnu-emacs@m.gmane.org; Tue, 05 Jun 2018 12:15:27 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38888) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQDq3-0006Zn-Ky for help-gnu-emacs@gnu.org; Tue, 05 Jun 2018 11:25:36 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fQDpy-0001ij-OH for help-gnu-emacs@gnu.org; Tue, 05 Jun 2018 11:25:35 -0400 Original-Received: from mail-wm0-x22a.google.com ([2a00:1450:400c:c09::22a]:51894) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fQDpy-0001hB-Hh for help-gnu-emacs@gnu.org; Tue, 05 Jun 2018 11:25:30 -0400 Original-Received: by mail-wm0-x22a.google.com with SMTP id r15-v6so5733303wmc.1 for ; Tue, 05 Jun 2018 08:25:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:subject:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=0xrXgzvBu5rYPvY+cl1nUmf6LqykkV07MPbCzVZnrNs=; b=pZi6oV7MyF+T49FmfV9nzId8y83LtuY+E1D8tXeFfMfgxdILq26QUbsvit4hEGMheQ dzt6G+B4l+eThJuhKX5LO59DCF3ylKh3wfIq55ThRlElzj72GdaOOWpWyQiZamoKHDQg M50ReFXzhyF7adeZF6YVkI/m6dqZ3RIu+RGenptdCLT5P9RVrdav5fjlVRqeptf0baXs hFPXgz9eQoW4HCPYXndzVWR1z43ugWkSgg/SU0nyKgWDxSjbJK6pOMWgQBz215ErkYJq sMKVoi4YGeNCYZX+ATANkfBbxGJd3Z8eokILsj8Ni5OwxOi9M1HjNiM+7lDRKTMIppAX Abyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0xrXgzvBu5rYPvY+cl1nUmf6LqykkV07MPbCzVZnrNs=; b=inqkGXD8H5cpQb5h2WV5yUv2Sujn7oLNirWGckkaPpCapp5GwCvAjH5KAYK62qicql HVUtl7AZk4sIM+CXS2gv6zZ+pulxqwbxE+gsMOdpTeMMQeeQhnTqDFTzzotWzSdOsQXD IM8ZFoDKPFI9umntcJGAqxJva9U3eItUBiC6Hi/VZYLFol9Gq1AepFYfr3vHXSeYJ3rO 2ahydSy0+iE40r3I+jPxdVqCRcEx6inwXnLfmAnmfyNgmz8E07SUMVp24uuc/QCVqIDw kuFI+7KsIfhNLhDtqLhoKpf4LYIX/mUZjx8MBmBOZukTtefU4iAe6xDG1Al49Kl0PD7q GuyA== X-Gm-Message-State: APt69E2onMN2C2vx8jzycHm+Q1KIdo0y/OYLm52h77uWM9IHmtAdXUdg ivHQV1y0du0qTOvMjtJJIFQT X-Google-Smtp-Source: ADUXVKI0QVRBVR8abZjCUAz+5cfMpQFTC7YD/yPWK/1sbOZSilh1ah2XeICfFBzeKezUQBXrhkPYdA== X-Received: by 2002:a1c:d2cb:: with SMTP id j194-v6mr4628102wmg.129.1528212329112; Tue, 05 Jun 2018 08:25:29 -0700 (PDT) Original-Received: from Yoda ([109.245.127.187]) by smtp.gmail.com with ESMTPSA id k28-v6sm65437099wrk.46.2018.06.05.08.25.27 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Jun 2018 08:25:28 -0700 (PDT) In-Reply-To: <86lgbt4cb6.fsf@zoho.com> X-Mailer: Claws Mail 3.11.1 (GTK+ 2.24.31; x86_64-redhat-linux-gnu) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::22a X-Mailman-Approved-At: Tue, 05 Jun 2018 12:11:27 -0400 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:116969 Archived-At: On Tue, 05 Jun 2018 15:01:33 +0200 Emanuel Berg wrote: > 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} Umm, not to be a nitpick, but how about you change the minus in the above line into a plus? I mean, 1.75 is equal to 1+3/4, rather than 1-3/4 (the latter obviously being equal to 0.25). I kind-of assume you know what you are doing, but still, other people may get confused. > echo ${whole}${frace} > fi > } > # $ ths 2.0 > # 2 > # $ ths 1.75 > # 1-3/4 > HTH, :-) Marko