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

Impossible to compare Double or Float with Integer or Byte

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.0-beta-2
    • 1.0-beta-3
    • None
    • None

    Description

      It should be possible to seamlessly compare numerical types.
      The following code issue a ClassCastException

      groovy> Byte b = new Byte("3")
      groovy> f = 4.45
      groovy> isGreater = f > b
      groovy>
      Caught: java.lang.ClassCastException
      java.lang.ClassCastException
      at java.lang.Double.compareTo(Double.java:642)
      at org.codehaus.groovy.runtime.Invoker.compareTo(Invoker.java:267)
      at org.codehaus.groovy.runtime.InvokerHelper.compareGreaterThan(InvokerH
      elper.java:231)
      at CommandLine6.run(CommandLine6.groovy:2)
      at groovy.lang.GroovyShell.evaluate(GroovyShell.java:220)
      at groovy.lang.GroovyShell.evaluate(GroovyShell.java:199)
      at groovy.ui.InteractiveShell.run(InteractiveShell.java:100)
      at groovy.ui.InteractiveShell.main(InteractiveShell.java:71)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
      java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
      sorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      at org.codehaus.classworlds.Launcher.launchStandard(Launcher.java:410)
      at org.codehaus.classworlds.Launcher.launch(Launcher.java:344)
      at org.codehaus.classworlds.Launcher.main(Launcher.java:474)

      Attachments

        Activity

          People

            Unassigned Unassigned
            guillaume Guillaume Sauthier
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: