Am 09.10.2015 um 20:23 schrieb Winnebeck, Jason:
I’ve been struggling with types in math operations in Groovy. I think
there is an error in the documentation?
http://groovy-lang.org/syntax.html#_math_operations
It says that int and BigDecimal result in double, but it doesn’t, it
results in BigDecimal instead. It appears this holds for byte, char,
short, and long as well.
assert (15.0 + 1).class == BigDecimal
integral type with BigDecimal should lead to BigDecimal. So yes, that's
a bug.
Are there other errors in that table? It seems so… because byte + short
is a byte and not an int as mentioned in that table:
assert ((byte)1 + (short)1).class == Byte
that assert fails for me. I get int (well Integer).
Anyway.... the BigDecimal part in that table looks wrong... BigDecimal
leads always to BigDecimal, except for float/double.
bye blackdrag
--
Jochen "blackdrag" Theodorou
blog: http://blackdragsview.blogspot.com/