|
From: | Jean Louis |
Subject: | Re: math (was: Re: not good proposal: "C-z <letter>" reserved for users) |
Date: | Sat, 13 Feb 2021 18:08:43 +0300 |
User-agent: | Mutt/2.0 (3d08634) (2020-11-07) |
* Emanuel Berg via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org> [2021-02-13 17:56]: > > Jean Louis wrote: > > > >> (defun pct-of-number-in-total (number total) > >> "Return the percentage that NUMBER represents in a TOTAL." > >> (let* ((percent (/ (float total) 100)) > >> (percentage (/ (float number) percent))) > >> percentage)) > > > > (defun percent (n d) > > (let ((pct (* 100 (/ n d 1.0)))) > > (message "%.1f%%" pct))) > > > > (percent 13973 204612) ; 6.8% > > The 1.0 and (float) just don't look good. Maybe one should do > it onee time and be done with Thanks, I knew somebody will improve it for free. Now I will use: (defun pct-of-number-in-total (number total) "Return the percentage that NUMBER represents in a TOTAL." (/ number total 0.01))
[Prev in Thread] | Current Thread | [Next in Thread] |