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

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

Re: not good proposal: "C-z <letter>" reserved for users


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

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))
> (pct-of-number-in-total 13973 204612) yields 6.8290227357144255

(defun percent (n d)
  (let ((pct (* 100 (/ n d 1.0))))
    (message "%.1f%%" pct)))

(percent 13973 204612) ; 6.8%

One thing I don't understand tho - from the `format' docstring

  For %e and %f sequences, the number after the "." in the
  precision specifier says how many decimal places to show; if
  zero, the decimal point itself is omitted.

Still (percent 0 200) ; 0.0%

Or does that refer to "if one _sets_ it to zero"

(message "%.0f%%" 0) ; 0%

Right, so that's it... Yeah, so obvious, saying it makes one
confused instead :)

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