help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: 1.75 -> 1-3/4


From: Emanuel Berg
Subject: Re: 1.75 -> 1-3/4
Date: Tue, 05 Jun 2018 20:06:45 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux)

Marko Vojinovic 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.

Ha ha :D

-- 
underground experts united
http://user.it.uu.se/~embe8573


reply via email to

[Prev in Thread] Current Thread [Next in Thread]