On Sunday, June 25, 2017 at 1:55:42 AM UTC-5, henrik42 wrote:
>
> Alex,
>
> Am Samstag, 24. Juni 2017 13:38:55 UTC schrieb Alex Miller:
>>
>>
>>
>> Oh, I thought because there is the float-function floats are supported. 
> Clojure could use "0.2f" to print/read floats and still use double "0.2" as 
> the default (but float's "Infinity" may be challenging ;-)
>

Rich decided long ago that Clojure would only support primitive longs and 
primitive doubles (for reading, function invocation, function return, etc). 
Primitive floats, ints, shorts are supported only for the purposes of Java 
interop (invoking Java methods primarily) and to some limited degree in 
tight loop/recur loops.
 

> Java uses f2d when comparing float vs. double and when mixing floats and 
> double for +/-/etc. All I'm saying is that Clojure *could* use (Double. 
> (str f)) instead of f2d in these cases. That would make (= (double 0.2) 
> (Double. (str (float 0.2)))) ;; -> true
>
> Talking about infinity: #{Double/POSITIVE_INFINITY} ;; -> #{Infinity} But 
> #{Infinity} ;; -> Exception: Unable to resolve symbol: Infinity in this 
> context. Is there a way to deal with this at the moment?
>

Discussion on this occurring 
here https://dev.clojure.org/jira/browse/CLJ-1074
 

> This is under discussion in a ticket at 
>> http://dev.clojure.org/jira/browse/CLJ-1649. It is definitely a bug with 
>> float/double hash consistency. My personal vote in this case is that floats 
>> and doubles should just never compare equals, period. Due to the example up 
>> top, you're almost never going to get predictable results and you should 
>> just not use floats. Or at least not use a mix of floats and doubles.
>>
>  
> And throw an exception when doing so? Or is it GIGO?
>

No, if you use = would just return false for all comparisons of floats and 
doubles, so there is no need for hash consistency.
 

-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to