all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bike shifting - output decimal in percent
@ 2019-05-19  1:34 Emanuel Berg
  2019-05-19  3:50 ` Drew Adams
  0 siblings, 1 reply; 12+ messages in thread
From: Emanuel Berg @ 2019-05-19  1:34 UTC (permalink / raw)
  To: help-gnu-emacs

How do I output a decimal float digit
0 <= x <= 1 into percent? ("A percentage?"
Correct English?)

I asked at #emacs@irc.freenode.net and got the
below answer, which, as you see, works fine.

But I wonder if/why-not there is/isn't
a built-in way to do it?


Context:

;; thanks to friend at #emacs
(defun percent-string (decimal)
  (concat
   (number-to-string
    (round (* 100 decimal)) ) "%") )
;; test: (percent-string 0.42857142857142855) ; "43%"

(defun bike-compute-step (from to)
  (percent-string
   (/ (- from to)
      from
      1.0) ))
;; test - should be 43% for
;; one 42t and one 24t chainring
;; according to an article in the spring 2019 issue
;; of "Bicycle Quarterly" (ISSN 1941-8809) -
;; (bike-compute-step 42 24) ; "43%"


Whole file:

  http://user.it.uu.se/~embe8573/emacs-init/bike.el

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




^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2019-05-19 14:26 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-05-19  1:34 bike shifting - output decimal in percent Emanuel Berg
2019-05-19  3:50 ` Drew Adams
2019-05-19  3:57   ` Drew Adams
2019-05-19  4:09     ` Drew Adams
2019-05-19  7:05   ` Emanuel Berg
2019-05-19  7:35     ` Emanuel Berg
2019-05-19  7:53       ` Tomas Nordin
2019-05-19  8:02         ` Emanuel Berg
2019-05-19  8:15           ` Tomas Nordin
2019-05-19  8:26             ` Emanuel Berg
2019-05-19 14:26       ` Drew Adams
2019-05-19 14:15     ` Drew Adams

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.