jscience
  1. jscience
  2. JSCIENCE-43

Exception when showing Measure of value 0

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: current
    • Fix Version/s: Version 6.0
    • Component/s: www
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: PC

    • Issuezilla Id:
      43

      Description

      Hi,

      I tried to convert 273.15K to Celsius (->0°C). Using the following code I got an
      exception:

      org.jscience.physics.measures.MeasureFormat.setInstance(org.jscience.physics.measures.MeasureFormat.getExactDigitsInstance());

      org.jscience.physics.measures.Measure<javax.measure.quantities.Temperature>
      measKelvin = org.jscience.physics.measures.Measure.valueOf(273.15, KELVIN);

      org.jscience.physics.measures.Measure<javax.measure.quantities.Temperature>
      measCelsius = measKelvin.to(CELSIUS);

      org.jscience.physics.measures.Measure<javax.measure.quantities.Temperature>
      measKelvin1 = measCelsius.to(KELVIN);
      System.out.println(measKelvin + " to " + measCelsius + " back to " +
      measKelvin);

      Exception in thread "main" java.lang.IllegalArgumentException: digits: -2147483635
      at javolution.text.TypeFormat.format(Unknown Source)
      at javolution.text.Text.valueOf(Unknown Source)
      at
      org.jscience.physics.measures.MeasureFormat$ExactDigitsOnly.format(Unknown Source)
      at
      org.jscience.physics.measures.MeasureFormat$ExactDigitsOnly.format(Unknown Source)
      at javolution.text.TextFormat.format(Unknown Source)
      at org.jscience.physics.measures.Measure.toText(Unknown Source)
      at javolution.context.RealtimeObject.toString(Unknown Source)
      at java.lang.String.valueOf(String.java:2615)
      at java.lang.StringBuilder.append(StringBuilder.java:116)
      at com.rieter.common.Quantities.main(Quantities.java:552)

      Using the same code with 273.16K there is no problem.

      Thanks
      Mario

        Activity

        Hide
        mruetti added a comment -

        Tested with 3.3 beta and it works now!

        Show
        mruetti added a comment - Tested with 3.3 beta and it works now!
        Hide
        dautelle added a comment -

        Fixed for 3.3.0

        Show
        dautelle added a comment - Fixed for 3.3.0

          People

          • Assignee:
            jscience-issues
            Reporter:
            mruetti
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: