You’re right about BigInteger, I did see that (but did not test it). The table does show it as well. I am talking about BigDecimal. The bullet points only cover BigDecimal with BigDecimal and BigDecimal with float|double but say nothing about BigDecimal with integral types.


From what I can tell the table should be updated so that the byte, char, short, int, and long rows in BigDecimal column should say BigDecimal and float and double stay double and BigDecimal stays BigDecimal. I’ll put in a PR for that.




From: Pascal Schumacher []
Sent: Friday, October 09, 2015 3:25 PM
Subject: Re: Math Operations


The documentation says "binary operations involving BigInteger and any other integral type result in BigInteger".

If I understand the table correctly it show that int and BigInteger result in BigInteger.

Am I missing something?


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


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


I would put in a PR to fix up that doc but I’m not sure I understand how it all works. Normally when I do maths I try to stick all to primitive types or all to BigDecimal types. Today I’m trying to make sure I don’t accidentally go from BigDecimals to float/double.

Jason Winnebeck

Software Engineer III Contractor - IT Software Development | Windstream

600 Willowbrook Office Park, Rochester, NY 14450 |

o: 585.794-4585


This email message and any attachments are for the sole use of the intended recipient(s). Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message and any attachments.