You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
int ints[][]= new int[1][1];
int min, diff;
diff = 100;
min = 20;
ints[0][0] = 40;
// As is, no cast
float dist = (ints[0][0] - min) /diff;
System.out.println("dist without cast is " + dist);
// With cast to float
dist = (float) (ints[0][0] - min) /diff;
System.out.println("dist with cast is " + dist);
Output:
dist without cast is 0.0
dist with cast is 0.2
The text was updated successfully, but these errors were encountered:
bioformats/components/formats-bsd/src/loci/formats/gui/AWTImageTools.java
Line 1658 in 6fa35f6
Since ints[][], min, and diff are all ints, the equation is done with Integer accuracy and not Float accuarcy.
To get Float accuracy from the equation, a float cast is needed
Maybe
float dist = (float) (ints[i][j] - min) / diff;
Example:
Output:
dist without cast is 0.0
dist with cast is 0.2
The text was updated successfully, but these errors were encountered: