Skip to content

Commit

Permalink
62: Adds range check for crop percentage values
Browse files Browse the repository at this point in the history
  • Loading branch information
cnagel committed Aug 23, 2024
1 parent 07d18f7 commit 5a70665
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ private RelativeCroppingString() {
}

private static String toPercentage(double fraction) {
return DECIMAL_FORMAT.format(Math.round(fraction * 1000d) / 10d);
double percentage = Math.round(fraction * 1000d) / 10d;
percentage = Math.max(0.0, percentage);
percentage = Math.min(100.0, percentage);
return DECIMAL_FORMAT.format(percentage);
}

}

0 comments on commit 5a70665

Please sign in to comment.