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

BigDecimal unnecessarily coerced into double on method invocation

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.0-JSR-5
    • 1.0-JSR-6
    • None
    • None

    Description

      This bug occurs in MetaClassHelper.java on line 393. It unnecessarily creates a new BigDecimal when one was already passed in. Calling doubleValue() changes the original value.

      Java Class:
      import java.math.BigDecimal;
      class BigDecimalEcho {
      public static BigDecimal echoX ( BigDecimal x, BigDecimal y)

      { return x; }

      }

      GroovyTest:
      import BigDecimalEcho

      println BigDecimalEcho.echoX(9.95, 1.0)
      println BigDecimalEcho.echoX(9.95, 1)

      Output:
      9.95
      9.949999999999999289457264239899814128875732421875

      Attachments

        Activity

          People

            blackdrag Jochen Theodorou
            jshickey Scott Hickey
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: