--
You received this message because you are subscribed to the Google Groups "Clojure Dev" group.
To post to this group, send email to cloju...@googlegroups.com.
To unsubscribe from this group, send email to clojure-dev...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/clojure-dev?hl=en.
For reasons passing understanding, all calls have their results
converted from int->long and float->double.
https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Reflector.java#L491
> user=> (.println System/out (.floatValue 3.14))
> 3.140000104904175
>
> This last case seems to be the troubling one, because I'm not actually able to invoke the primitive float version of .println, instead the primitive float seems to be cast to a primitive double (or a Double), which causes the slightly different number to be printed.
This is what float casts are for:
(.println System/out (float 3.14))
Stu
Also, it seems like it's impossible to determine if you actually have a float vs. a double.
Clojure 1.3.0-alpha3
user=> (type (float 3.14))
java.lang.Double
user=> (class (float 3.14))
java.lang.Double
user=> (type (.floatValue 3.14))
java.lang.Double
user=> (class (.floatValue 3.14))
java.lang.Double
Perhaps 'float is actually returning a float, but using it with type and class it gets upcast/boxed to a Double. Do type and class need to be overloaded with a version that takes primitives? Or what is going on here?