Have you checked out clojure-contrib.math's abs function?  It appears
to do the right thing for the cases you listed.

On Nov 2, 4:22 pm, box <somethingital...@gmail.com> wrote:
> Math/abs doesn't always return positive numbers. example:
>
> user=> (def min-int -2147483648)
> #'user/min-int
>
> user=> min-int
> -2147483648
>
> user=> (Math/abs min-int)
> -2147483648
>
> user=> (def min-int+1 (+ 1 min-int))
> #'user/min-int+1
>
> user=> min-int+1
> -2147483647
>
> user=> (Math/abs (- min-int+1 1))
> -2147483648
>
> (Math/abs (- Integer/MIN_VALUE 1))
> 2147483649
>
> so, in order to solve this problem, clojure needs it's own ABS, or it
> needs to convert a negative int approaching Integer/MIN_VALUE to
> something else before it reaches Integer/MIN_VALUE.
>
> so, does it sound sane for clojure to fix java's surprises?

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to