Thanks for the experience report. I've copied it into the ticket's description along with a link to this discussion.
If you have an account on JIRA, you can vote for the ticket. More votes might get the ticket some attention earlier than fewer votes. If you don't already have one, you can create a JIRA account by clicking on the "Log In" link near the top right of the following page, and then click the "Sign up" link. http://dev.clojure.org/jira/browse/CLJ To vote, find the JIRA ticket you want and click the "Vote" link. Here is a link to this particular ticket. http://dev.clojure.org/jira/browse/CLJ-1118 The earliest such a change would get into an official Clojure release would be Clojure 1.6.0, but it could make it into a 1.6 alpha or beta release sooner. You are of course welcome to apply the patch locally to your own copy of the Clojure source code and build a jar file from that. How easy or difficult that would be to deploy in your local setup depends on various factors, e.g. whether you have a local Maven repo that your projects use, and your willlingness to update the Clojure version in all of your Leiningen/Maven/whatever config files. Andy On Tue, Sep 3, 2013 at 3:49 PM, Korny Sietsma <ko...@sietsma.com> wrote: > It'd be great if this got fixed - we met an ugly bug yesterday due to this > on our project. > > (Our system validates that the sum of two monetary fields A and B equals > the sum of two monetary fields C and D. We parse the fields via Cheshire > with conversion to bigdecimal turned on - but any fields with no fractional > part get parsed as Integers anyway. So if A=$1.50, B=$1.50, C=$2 and D=$1, > (== (+ A B) (+ C D)) is false... ) > > - Korny > > > On 2 August 2013 15:25, CGAT <genovese...@gmail.com> wrote: > >> Terrific, Andy, thanks. I will definitely take a look. >> >> >> On Friday, August 2, 2013 1:16:14 AM UTC-4, Andy Fingerhut wrote: >> >>> I agree, which is why I wrote a patch for the ticket >>> http://dev.clojure.org/jira/**browse/CLJ-1118<http://dev.clojure.org/jira/browse/CLJ-1118> >>> >>> (Depending on when you read this, dev.clojure.org may not be accessible >>> due to a recent DNS update made by the Clojure folks. Wait a while and try >>> again.) >>> >>> It makes not only the change you suggest, but also another one to how >>> hash is calculated for BigDecimal values, so that hash is still consistent >>> with =. Take a look at it and see if you think it is correct. >>> >>> Andy >>> >>> >>> On Thu, Aug 1, 2013 at 9:28 PM, CGAT <genov...@gmail.com> wrote: >>> >>>> My understanding of == is that it is intended to establish numerical >>>> equivalence >>>> across types. But I think that basic contract fails with BigDecimal. >>>> For instance, >>>> >>>> (== 1M 1.0M) ; => false >>>> >>>> because the scale properties of these numbers are different. So then >>>> of course: >>>> >>>> [(== 1 1N 1.0) (== 1 1N 1.0 1M) (== 1 1N 1.0 1.0M) (== 1 1.0 1N 1.0M)] >>>> ; => [true true true false] >>>> and >>>> [(== 1.0M 1.0) (== 1.0 1) (== 1 1N) (== 1N 1.0M)] >>>> ; => [true true true false] >>>> >>>> I find your lack of transitivity (and commutativity) ... disturbing. >>>> >>>> The issue is that there are two notions of equality for BigDecimal, >>>> equals and compareTo, where equals compares value *and* scale while >>>> compareTo compares numerically. >>>> >>>> The other numeric types use equals for equivalence, quite reasonably. >>>> But in class BigDecimalOps in clojure/lang/Numbers.java, I propose >>>> that >>>> >>>> public boolean equiv(Number x, Number y){ >>>> return toBigDecimal(x).equals(**toBigDecimal(y)); >>>> } >>>> >>>> should be >>>> >>>> public boolean equiv(Number x, Number y){ >>>> return toBigDecimal(x).compareTo(**toBigDecimal(y)) == 0; >>>> } >>>> >>>> to give the proper sense of equivalence. >>>> >>>> I haven't had a chance yet to recompile with this change to test it, >>>> but we do have >>>> >>>> (zero? (. 1.0M (compareTo 1M))) ; => true >>>> (zero? (. 1.0000M (compareTo 1M))) ; => true >>>> (zero? (. 1.000M (compareTo 1.0M))) ; => true >>>> >>>> as desired. >>>> >>>> Reactions? >>>> >>>> Best, >>>> >>>> Chris >>>> >>>> -- >>>> -- >>>> You received this message because you are subscribed to the Google >>>> Groups "Clojure" group. >>>> To post to this group, send email to clo...@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+u...@**googlegroups.com >>>> >>>> For more options, visit this group at >>>> http://groups.google.com/**group/clojure?hl=en<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+u...@**googlegroups.com. >>>> >>>> For more options, visit >>>> https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out> >>>> . >>>> >>>> >>>> >>> >>> -- >> -- >> 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/groups/opt_out. >> >> >> > > > > -- > Kornelis Sietsma korny at my surname dot com http://korny.info > .fnord { display: none !important; } > > -- > -- > 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/groups/opt_out. > -- -- 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/groups/opt_out.