Am 09.10.2015 um 20:55 schrieb Winnebeck, Jason:
OK, so int + BigDecimal is a bug in documentation then.

I am using Groovy Shell (2.4.3, JVM: 1.8.0_45), and in that I run this:

groovy:000> println (((byte)1 + (short)1).class)
class java.lang.Byte
===> null
groovy:000> println ((byte)1 + (short)1)
2
===> null

I wondered if Groovy was somehow picking the "smallest" type, because byte + short 
-> byte makes no sense at all unless Groovy was looking at the result. However, this 
doesn't look good at all:
groovy:000> println ((byte)1 + (short)700)
-67

It looks like it really is doing the math as bytes. What version of Groovy are 
you using where it works?

I just checked several version and you are right. This used to happen between 1.7.0 and 2.4.3 Always interesting to see a long term bug, nobody has bothered reporting before or went unnoticed. Anyway, 1.6.x and older versions behave right, as does 2.4.4. It also means we have a lot of versions in which primopts (Groovy 1.8.0+) and normal Groovy do behave different.... as well as static compilation and some versions of indy.


 bye blackdrag


--
Jochen "blackdrag" Theodorou
blog: http://blackdragsview.blogspot.com/

Reply via email to