Re: Contagious BigDecimals?

2014-05-07 Thread Mars0i
Reviving a thread from three years ago (feel free to point me to something more recent) ... In Clojure 1.6: (class (+ 1 1.0M)) ; == java.math.BigDecimal (class (+ 1.0 1.0M)) ; == java.lang.Double So combining a BigDecimal with a Long produces a BigDecimal, but combining it with a Double

Re: Contagious BigDecimals?

2014-05-07 Thread Stephen Gilardi
On May 7, 2014, at 12:11 PM, Mars0i marsh...@logical.net wrote: To me, the fact that BigDecimal is contagious sometimes but not always, seems confusing in a way that could encourage bugs. The fact that BigInts are contagious would also lead one to assume that BigDecimals are contagious. I

Re: Contagious BigDecimals?

2014-05-07 Thread Mars0i
On Wednesday, May 7, 2014 1:00:01 PM UTC-5, squeegee wrote: On May 7, 2014, at 12:11 PM, Mars0i mars...@logical.net javascript: wrote: To me, the fact that BigDecimal is contagious sometimes but not always, seems confusing in a way that could encourage bugs. The fact that BigInts are

Contagious BigDecimals?

2011-05-23 Thread Chas Emerick
my raising this question is merely revealing (again) my lack of understanding of floating-point representations and such. The quorum in #clojure came up with some suggestions for why contagious BigDecimals might not be desirable/practical: The management of precision is fundamentally too

Re: Contagious BigDecimals?

2011-05-23 Thread Mark Engelberg
doubles are inherently inexact; they are approximations of a real number. If you add an inexact number and an exact number, the only thing that makes sense is to return something that is inexact. BigInt contagion is different, because you are adding two exact things, it's just a question of

Re: Contagious BigDecimals?

2011-05-23 Thread pmbauer
If you add an inexact number and an exact number, the only thing that makes sense is to return something that is inexact. So why then are double's contagious when mixing double and float values in a calculation? Doubles and floats are both inexact, but floats are at least less exact than

Re: Contagious BigDecimals?

2011-05-23 Thread pmbauer
(re: why then...) P.S. I mean in more general context of how double contagion is handled in most languages. Clojure 1.3 alphas auto-promote floats to doubles in almost every case eg. exception: (type (float 1.0)) On Monday, May 23, 2011 4:16:48 PM UTC-7, pmbauer wrote: If you add an inexact