Re: Numbers API has no abs function

2008-10-29 Thread Paul Drummond
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! --~--~-~--~~---

Re: Numbers API has no abs function

2008-10-29 Thread [EMAIL PROTECTED]
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

Numbers API has no abs function

2008-10-29 Thread Paul Drummond
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