groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Winnebeck, Jason" <>
Subject Integer primitive division
Date Fri, 23 Oct 2015 20:47:03 GMT
Is there any way to perform primitive integer division in Groovy compile static mode? If I


Then it coverts 12 and 2 to Integer objects, calls a method that performs BigDecimal division,
then calls "as int" (not just intValue) on the result, which itself does instanceof checks.

I tried intdiv, and it is more efficient, but it still converts to and from Integer objects
so that it can do A.intValue() / B.intValue(), and storing that result in an Integer itself.

I see if I just do 12 + 2, it does a true primitive operation in the bytecode. Is there any
way to perform primitive division in Groovy the same way it is done in Java?

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.

View raw message