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

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

Re: math (was: Re: not good proposal: "C-z <letter>" reserved for users)


From: Emanuel Berg
Subject: Re: math (was: Re: not good proposal: "C-z <letter>" reserved for users)
Date: Sat, 13 Feb 2021 16:20:26 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Jean Louis wrote:

> 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))

But that's even better, one less function AND no 1.0 or
`float'.

(defun percent (n d)
  (let ((pct (/ n d 0.01)))
    (message "%.1f%%" pct)))
;; (percent 8  256) ; 3.1%
;; (percent 0 1337) ; 0.0%

-- 
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal




reply via email to

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