Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-4421

Casts should have higher precedence than mathematical operators

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Duplicate
    • 1.7.4
    • 2.4.4
    • Compiler
    • None

    Description

      The following test case executes successfully when compiled+executed as java. However it throws the exception "Cannot use mod() on this number type: java.math.BigDecimal with value: 10.7" when executed as groovy.

      public class TesCastPrecedence {
          @org.junit.Test
          public void testCastWithMod() {
              long result = (long)10.7 % 3L;
              System.out.println(result);
              org.junit.Assert.assertEquals(result, 1L);
          }
      }
      

      Attachments

        Activity

          People

            paulk Paul King
            jwadamson Jeffrey Adamson
            Votes:
            3 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: