Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8152293

Incomplete fraction reduction in getValueAsString() for TIFFTag.TIFF_RATIONAL, TIFFTag.TIFF_SRATIONAL

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • 9
    • client-libs

      Please use the following code:

        long r[][] = {{-1, -1}};
        int type = TIFFTag.TIFF_RATIONAL;
        TIFFField f = new TIFFField(new TIFFTag("tag", 666, 1 << type), type, r.length, r);
        System.out.println(f.getValueAsString(0));


      Output:
        r[][] = {{-1, -1}}; -> "1/1"
        r[][] = {{-3, -3}}; -> "1/1"
        r[][] = {{0, -3}}; -> "0/1"
        r[][] = {{-4, 2}}; -> "-2/1"
        r[][] = {{-4, -2}}; -> "2/1"

      but, at the same time:
        long r[][] = {{-2, -3}}; -> "-2/-3" (expected: "2/3")
      and
        long r[][] = {{2, -4}}; -> "2/-4" (expected: at least, "-2/4", but much better: "1/2")

      So some rudiments of reducing fractions are implemented in getValueAsString(), but it would be nice to complete them (at least in part of the signs) or remove them completely to avoid the mess.

      The same for TIFFTag.TIFF_SRATIONAL

            bpb Brian Burkhalter
            avstepan Alexander Stepanov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: