You’re right abo= ut 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 BigDe= cimal with BigDecimal and BigDecimal with float|double but say nothing about BigDecimal with integral types.

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

Jason

From:= Pascal Schumacher [mailto:pascalschumache= r@gmx.net]
Sent: Friday, October 09, 2015 3:25 PM
To: users@groovy.incubator.apache.org
Subject: Re: Math Operations

The documentation says "binary operations invol= ving `BigInteger` and an= y 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?

-Pascal

Am 09.10.2015 um 20:23 schrieb Winnebeck, Jason:

I’ve been struggling with types in math operat= ions in Groovy. I think there is an error in the documentation?<= /p>

It says that int and BigDecimal result in double, bu= t it doesn’t, it results in BigDecimal instead. It appears this holds= for byte, char, short, and long as well.

assert (15.0 &#= 43; 1).class =3D=3D BigDecimal

Are there other errors in that table? It seems so= 230; because byte + short is a byte and not an int as mentioned in that= table:

assert ((byte)1= + (short)1).class =3D=3D 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 tr= ying to make sure I don’t accidentally go from BigDecimals to float/double.

Jason Winnebeck

Software Engineer III Contractor - I= T Software Development | Windstream

600 Willowbrook Office Park, Rochester, NY= 14450