Skip to content

Commit

Permalink
Don't compare floating point numbers using ==
Browse files Browse the repository at this point in the history
  • Loading branch information
Bauke Scholtz committed Jan 12, 2017
1 parent d1d638a commit 4ac9ba5
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/java/org/omnifaces/el/functions/Numbers.java
Expand Up @@ -248,7 +248,7 @@ private static String formatBaseUnit(Number number, int base, Integer fractions,
private static String formatBase(BigDecimal decimal, int base, Integer fractions, boolean iec, String unit) {
int exponent = (int) (Math.log(decimal.longValue()) / Math.log(base));
BigDecimal divisor = BigDecimal.valueOf(Math.pow(base, exponent));
BigDecimal divided = (divisor.doubleValue() == 0.0) ? divisor : decimal.divide(divisor);
BigDecimal divided = (divisor.signum() == 0) ? divisor : decimal.divide(divisor);
int maxfractions = (fractions != null) ? fractions : (PRECISION - String.valueOf(divided.longValue()).length());
BigDecimal formatted;

Expand Down

0 comments on commit 4ac9ba5

Please sign in to comment.