Uploaded image for project: 'Commons IO'
  1. Commons IO
  2. IO-101

The method EndianUtils.writeSwappedDouble() and EndianUtils.readSwappedDouble() do not match!

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Fixed
    • 1.2
    • 1.3
    • Streams/Writers
    • None
    • I was running Windows XP SP2 and using Commons IO 1.2, Java 1.5 update 9 when I got this problem.

    Description

      Code:

      public static void main(String[] args) {

      double[] tests = new double[]

      {34.345, -345.5645, 545.12, 10.043, 7.123456789123}

      ;
      for (int i = 0; i< tests.length ;i++)

      { byte[] buffer = new byte[8]; EndianUtils.writeSwappedDouble(buffer, 0, tests[i]); double val = EndianUtils.readSwappedDouble(buffer, 0); System.out.println(val); }

      }

      Result:
      34.344969482421874
      -345.5645
      545.11951171875
      10.043
      7.123456789123

      Note:
      In my opinion the values shouldn't be changed at all.

      Attachments

        1. IO-101.patch
          2 kB
          Henri Yandell

        Activity

          People

            Unassigned Unassigned
            zepinto José Pinto
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: