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

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

Re: Evaluation of "standard" style math expresssions.


From: Marco Parrone
Subject: Re: Evaluation of "standard" style math expresssions.
Date: Tue, 21 Sep 2004 12:07:56 GMT
User-agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux)

Alex Polite on 21 Sep 2004 11:48:13 GMT writes:

> I know how to evaluate mathematical expressions expressed in lisp in
> any emacs buffer.  (eg (+ 17 42))
>
> But I'd like to be able to eval expression where the notation is the
> kind you learn in school (eg (17 + 42))
>
> How do I do it?

you can pipe the expression to bc.

for example on a line you have

1 + 2 * 3

you can set the mark `C-SPC' at the beginning of the line, then move
the point in the next line `C-n', then pipe the line to bc `M-| bc RET'

try with

9 / 2

you get 4, you may want to do this instead

scale=1
9 / 2

(set the mark at the beginning of the first line and move the point
after the second), so to get `4.5'.

for more informations about bc syntax, do `M-x man RET bc RET'.

-- 
Marco Parrone <marc0@autistici.org>
fingerprint: F7D4 527B DE97 4090 657B  6E4E 8B63 1167 (4507 0AD6)

reply via email to

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