Skip to content

Commit

Permalink
Update calculateXGcd to throw exception when result is zero
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickmichalik committed Sep 25, 2023
1 parent 34b2296 commit c13ce22
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ internal fun Iterable<Iterable<ChartEntry>>.calculateXGcd(): Float {
}
if (gcd == -1f) gcd = 1f
}
return gcd ?: 1f
return gcd?.also {
require(it != 0f) { "The precision of the x values is too large. The maximum precision is two decimal places." }
} ?: 1f
}

internal fun Iterable<Iterable<ChartEntry>>.calculateStackedYRange(): ClosedFloatingPointRange<Float> =
Expand Down

0 comments on commit c13ce22

Please sign in to comment.