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

float to decimal false parse

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Blocker
    • Resolution: Won't Fix
    • 1.6.3
    • None
    • parser
    • None
    • suse linux enterprise 64 bit

    Description

      hi i just tried some groovy by following http://pleac.sourceforge.net/pleac_groovy/numbers.html
      code:

      import java.text.*
       int nb = 0
      try {
          nb = NumberFormat.getInstance().parse('33.5') // '.5' will be ignored
          nb = NumberFormat.getInstance().parse('abc')
      } catch (ParseException ex) {
          assert ex.getMessage().contains('abc')
      }
      assert nb == 33
      

      i get the error Caught: java.lang.AssertionError: Expression: (nb == 33). Values: nb = 335

      and when i do println nb it gives me the value 335 !
      i categorize this as blocker because it can block the whole system if youre working with floats castings

      greeets umit

      Attachments

        Activity

          People

            blackdrag Jochen Theodorou
            umit umit
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - 1h
                1h
                Remaining:
                Remaining Estimate - 1h
                1h
                Logged:
                Time Spent - Not Specified
                Not Specified