jscience
  1. jscience
  2. JSCIENCE-80

Unit.valueOf(CharSequence) parses large integer values incorrectly

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Blocker Blocker
    • Resolution: Unresolved
    • Affects Version/s: current
    • Fix Version/s: Version 6.0
    • Component/s: www
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

    • Issuezilla Id:
      80

      Description

      This problem was noticed in JScience 4.3.1.

      Unit.valueOf(CharSequence) parses large integer values incorrectly because
      UnitFormat.DefaultFormat.readLong(CharSequence,ParsePosition)
      uses an int to hold the intermediate results (int result) instead of a long.

      ---- Begin example code snippet ----
      final Unit<?> unitBigInteger = SI.KILO( NonSI.POUND_FORCE );
      final Unit<?> unitBigIntegerBad = Unit.valueOf( unitBigInteger.toString() );

      System.out.println( "unitBigInteger = " + unitBigInteger );
      System.out.println( "unitBigIntegerBad = " + unitBigIntegerBad );
      ---- End example code snippet ----

      ---- Begin output ----
      unitBigInteger = N*8896443230521/2000000000
      unitBigIntegerBad = N*313192101/400000000
      ---- End output ----

        Activity

        There are no comments yet on this issue.

          People

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

            Dates

            • Created:
              Updated: