[CLJ-455] Calculating large numbers results in java.math.BigIntegerArithmeticException Created: 08/Oct/10 Updated: 23/Oct/10 Resolved: 23/Oct/10 |
|
| Status: | Closed |
| Project: | Clojure |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | Backlog |
| Type: | Defect | ||
| Reporter: | Anonymous | Assignee: | Unassigned |
| Resolution: | Declined | Votes: | 0 |
| Labels: | None | ||
| Description |
|
(class (* 1000 1000 1000 1000 1000 1000 1000)) |
| Comments |
| Comment by Assembla Importer [ 23/Oct/10 10:52 PM ] |
|
Converted from http://www.assembla.com/spaces/clojure/tickets/455 |
| Comment by Assembla Importer [ 23/Oct/10 10:52 PM ] |
|
ataggart said: This is correct behavior with respect to 1.3.0 (yes, it's a breaking change). If one wants to allow numbers larger than what fits in a long to flow out of math ops, one needs to explicitly start with a BigInt: user=> (type 1N) clojure.lang.BigInt user=> (class (* 1000N 1000N 1000N 1000N 1000N 1000N 1000N)) clojure.lang.BigInt</code></pre> If one wants to allow autopromotion, one can use the new "tick" math ops: <pre><code>user=> (class (*' 1000 1000 1000 1000 1000 1000 1000)) clojure.lang.BigInt NB: Rich suspects almost no one should need these ops, and if you think you do, you're probably wrong. |