Hi, I'm trying to wrap the apfloat (arbitrary precision float, http://www.apfloat.org/apfloat_java) java library for a small project.
The idea is that the parameters of apfloat calculations get automatically converted to the Apfloat class. My test function is sqrtf (square root float) and the automatic conversion will allow me to write (sqrtf 5) without converting the 5 to an Apfloat object first. sqrtf uses a multimethod apf (apfloat) that takes care of the conversion. I wonder if this is the "correct" way of handling this in clojure or if I'm off track here? apfloat.clj: (ns apfloat) (import '(org.apfloat Apfloat Apint ApfloatMath)) (set! *warn-on-reflection* true) ; default precision (def *precision* 20) (def infinite Apfloat/INFINITE) (declare apf) (defn sqrtf [a] "sqrt of apfloat a" (ApfloatMath/sqrt (apf a))) (defmulti apf "creates an Apfloat." class) (defmethod apf Apfloat [#^Apfloat a] a) (defmethod apf Apint [#^Apint a] (if (= Apfloat/INFINITE (.precision a)) (.precision a (long *precision*)) a)) (defmethod apf Integer ([#^Integer a] (Apfloat. (.longValue a) (long *precision*)))) -- Martin -- 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 To unsubscribe from this group, send email to clojure+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.