Hello,

I was testing if my code works with Clojure 1.1.0-alpha-SNAPSHOT - the
full code is attached to this group (in files section) as parallel-
factorial*.clj .

The code works in 1.0.0, but blows up in 1.1.0 for bigger numbers.
After a bit of digging, I found that following function is the culprit
(working version shown):

;----------------------
(defn part-num [#^Integer n #^Integer m]
  (let [z (int (Math/floor (/ n m))) ; it generates float ranges
without the cast to int
        last-range (range (+ (* z m) 1) (+ n 1))
        ]
    (println z)
    (println last-range)
    (cons (if last-range last-range '(1))
          (for [x (range m)]
            (range (+ (* x z) 1) (+ (* (+ x 1) z) 1))
            )
          )
    )
  )
;----------------------

The problem is that without casting "z" to integer, the generated list
of ranges will have float numbers (and not integers), and that will
over-flow to infinity for large numbers when used in pfactorial
function.

No big deal, the fix is simple - this is heads up if more people find
their code broke with over-flow to infinity with the new version of
clojure.

It looks that float type "propagates" into arithmetics (and it did not
before) - better explanation welcome.

Kind regards,

Vladimir

-- 
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