You can use *unchecked-math* if you want unchecked arithmetic behaviour: => (set! *unchecked-math* true) true => (+ Long/MAX_VALUE Long/MAX_VALUE) -2
On Friday, 4 September 2015 23:04:27 UTC+8, Ali M wrote: > > Ok, so to give myself a safe and consistent way to reason about this > the addition operator, and probably other arithmetic operator > dont promote ouput > > so long+ long = long or exception > long + bigint = bigint > > if i need outpout promition i can use +' > > hmmm, a bit tricky > > On Friday, September 4, 2015 at 10:51:15 AM UTC-4, dennis wrote: >> >> Because the literal is readed as BigInt: >> >> user=> (class 6546546546546546546850348954895480584039545804 ) >> clojure.lang.BigInt >> >> 2015-09-04 22:48 GMT+08:00 Ali M <tclwa...@gmail.com>: >> >>> why? >>> >>> <REPL> >>> user=> (+ 6546546546546546546850348954895480584039545804 >>> 7548979534287548957345843954749357348757897) >>> 6554095526080834095807694798850229941388303701N >>> >>> user=> (+ Long/MAX_VALUE Long/MAX_VALUE) >>> >>> ArithmeticException integer overflow >>> clojure.lang.Numbers.throwIntOverflow (Numbers.java:1501) >>> >>> user=> Long/MAX_VALUE >>> 9223372036854775807 >>> </REPL> >>> >>> Why the much bigger numbers get promoted, and a smaller number overflows? >>> >>> Thank you >>> Ali >>> >>> -- >>> 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 >>> --- >>> 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/d/optout. >>> >> >> >> >> -- >> 庄晓丹 >> Email: killm...@gmail.com xzh...@avos.com >> Site: http://fnil.net >> Twitter: @killme2008 >> >> >> -- 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.