groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jochen Theodorou <>
Subject Re: Math Operations
Date Fri, 09 Oct 2015 18:46:24 GMT
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?
> 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

View raw message