On Oct 29, 1:46 pm, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
> How about this:
>
>(defn abs [x]
> (if (< x 0) (- x) x))
I will use that - I should have considered making my own version
rather than messing around with BigDecimal.abs(). Thanks!
--~--~-~--~~---
On Oct 29, 2:20 pm, Paul Drummond
<[EMAIL PROTECTED]> wrote:
> Is there reason why abs is not part of the Numbers interface?
I don't know, but...
> Would be nice to be able to use:
>
> (abs -1.0)
> 1
> (abs 1.0M)
> 1M
How about this:
(defn abs [x]
(if (< x 0) (- x) x))
This does wha
Is there reason why abs is not part of the Numbers interface?
Currently I need to differentiate between binary decimals and
BigDecimals:
(. java.lang.Math (abs -1))
1
(. -1M (abs))
1M
And if I accidentally use BigDecimal in the wrong place I get an NPE:
(. java.lang.Math (abs -1M))
java.lang.N