[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How is math-round different from other Calc functions?
From: |
Mattias Engdegård |
Subject: |
Re: How is math-round different from other Calc functions? |
Date: |
Wed, 2 Feb 2022 09:34:25 +0100 |
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?