Bigints are contagious, so (+ 1 XXXN) => XXYN. It occurred to me to ask, Why aren't BigDecimals contagious as well?
As things stand, (+ 1.0 1e400M) => Infinity — doubles are contagious, even when operated over with BigDecimals. I've never seen any discussion of BigDecimal contagion, so I assume 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 complicated and/or expensive. For example, providing a proper treatment of the differing levels of precision in e.g. (+ 1.0 1.15e400M) properly and efficiently may not be practical. Big ints subset the set of longs, so the promotion is straightforward. That's not the case for BigDecimals/doubles, where the latter's NaN and infinity values cannot be represented (AFAIK) by BigDecimal. The semantics around scale and rounding aren't easily reconciled with Clojure's existing operators. e.g.: => (/ 1M 3M) #<CompilerException java.lang.ArithmeticException: Non-terminating decimal expansion; no exact representable decimal result. These all seem like plausible rationales, but I thought I'd poll the list to see if anyone wanted to offer additional / further explanations. Continuing in my streak of numerics-related ignorance, - Chas -- 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