From: Thierry Volpiatto <thierry.volpiatto@gmail.com>
To: reader@newsguy.com
Cc: help-gnu-emacs@gnu.org
Subject: Re: Using `eval-expression' for math
Date: Thu, 03 Apr 2008 15:58:26 +0200 [thread overview]
Message-ID: <878wzvnipp.fsf@thievol.homelinux.org> (raw)
In-Reply-To: <8763uz3xss.fsf@newsguy.com> (reader@newsguy.com's message of "Thu, 03 Apr 2008 07:52:51 -0500")
reader@newsguy.com writes:
> Can someone show me how to do math with the eval-expression tool?
>
> (+ 2 2) and such simple problems I can do of course but when it comes
> to combining things like:
>
> 52 * 32 / 12
>
> Trying (* 52 32 ( / 12))
>
> or
> (/ 12 ( * 52 32 ))
>
> Goes nowhere fast, and from there I can't really imagine how else to
> arrange the parens.
>
> I get completely lost with the paren arrangement. Obviously my lisp
> skills are non-existent but I'm guessing there are a few basic rules
> that will allow me to do basic math like the problem above quickly
> without having to resort to my old stand by:
>
> awk 'BEGIN{print ((52 * 32) / 12)}'
>
> Or simply:
>
> awk 'BEGIN{print (52 * 32 / 12)}'
>
> Using awk takes longer to get it done than a quick `eval-expression' inside
> emacs would take.
>
Not sure to understand what you want to do , is it that?
,----
| ELISP> (/ (* 52 32) 12)
| 138
`----
Or that?
,----
| ELISP> (/ (* 52 32) 12.0)
| 138.66666666666666
`----
Or that?
,----
| ELISP> (/ (round (* 100 (/ (* 52 32) 12.0))) 100.0)
| 138.67
`----
In a shell?
,----
| thierry@thievol ~ $ bc -l<<EOF
| > scale=2
| > 52 * 32 / 12
| > EOF
| 138.66
`----
--
A + Thierry
Pub key: http://pgp.mit.edu
next prev parent reply other threads:[~2008-04-03 13:58 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-04-03 12:52 Using `eval-expression' for math reader
2008-04-03 13:53 ` Lennart Borgman (gmail)
2008-04-03 13:58 ` Thierry Volpiatto [this message]
2008-04-04 20:28 ` reader
2008-04-03 18:45 ` Nikolaj Schumacher
[not found] ` <mailman.9953.1207248322.18990.help-gnu-emacs@gnu.org>
2008-04-03 21:11 ` weber
2008-04-04 20:40 ` Jay Belanger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=878wzvnipp.fsf@thievol.homelinux.org \
--to=thierry.volpiatto@gmail.com \
--cc=help-gnu-emacs@gnu.org \
--cc=reader@newsguy.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.