From: "Mattias Engdegård" <mattiase@acm.org>
To: Daniele Nicolodi <daniele@grinta.net>
Cc: Emacs developers <emacs-devel@gnu.org>
Subject: Re: How is math-round different from other Calc functions?
Date: Wed, 2 Feb 2022 09:34:25 +0100 [thread overview]
Message-ID: <E87D695C-DF7A-419E-A6A7-5E7C0B556859@acm.org> (raw)
In-Reply-To: <6404b660-22e9-f140-94a1-b0e66caa34cb@grinta.net>
1 feb. 2022 kl. 22.12 skrev Daniele Nicolodi <daniele@grinta.net>:
> (defmath uround (x)
> (* (round (remove-units x)) (extract-units x)))
Looks like you may need to do `math-simplify` after `remove-units`, since `math-round` only works if its argument is a value, not an unsimplified expression such as `(* (float 4 0) 1)`.
> but it does if I replace round() with any other function:
>
> (defmath uplus (x)
> (* (1+ (remove-units x)) (calc-eval "kg" 'raw)))
That `(1+ ...)` becomes `(math-add ... x)` and presumably `math-add` makes an effort to simplify its arguments for other reasons.
At least, this is from a cursory look at the code. Does that make sense?
next prev parent reply other threads:[~2022-02-02 8:34 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-01 21:12 How is math-round different from other Calc functions? Daniele Nicolodi
2022-02-02 8:29 ` Andreas Schwab
2022-02-02 8:34 ` Mattias Engdegård [this message]
2022-02-02 8:51 ` Daniele Nicolodi
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=E87D695C-DF7A-419E-A6A7-5E7C0B556859@acm.org \
--to=mattiase@acm.org \
--cc=daniele@grinta.net \
--cc=emacs-devel@gnu.org \
/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.