-
Bug
-
Resolution: Unresolved
-
P4
-
9
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
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
- relates to
-
JDK-8169650 TIFFTag.TIFF_RATIONAL - no sign checks
-
- Open
-
-
JDK-8169651 TIFFTag.TIFF_RATIONAL, TIFFTag.TIFF_SRATIONAL - add zero denominator checks?
-
- Open
-