Mercurial > dive4elements > river
diff artifacts/src/main/java/org/dive4elements/river/utils/Formatter.java @ 9382:8ae7137b67d7
Fixed: avoiding NaN exception in BigDecimal rounding
author | mschaefer |
---|---|
date | Tue, 07 Aug 2018 14:06:49 +0200 |
parents | a0a2e68a1e11 |
children | 53e26734e4d2 |
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/utils/Formatter.java Tue Aug 07 12:43:53 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/utils/Formatter.java Tue Aug 07 14:06:49 2018 +0200 @@ -385,6 +385,10 @@ return Formatter.getFormatter(context, FLOWDEPTH_MAX_DIGITS, FLOWDEPTH_MAX_DIGITS); } + /** + * Decimal half even rounding of a flow depth value + * (throws an exception for NaN or Infinity) + */ public static BigDecimal roundFlowDepth(final double value) { return BigDecimal.valueOf(value).setScale(FLOWDEPTH_MAX_DIGITS, RoundingMode.HALF_EVEN); } @@ -393,6 +397,10 @@ return Formatter.getFormatter(context, 2, 2); } + /** + * Decimal half even rounding of a W value + * (throws an exception for NaN or Infinity) + */ public static BigDecimal roundW(final double value) { return BigDecimal.valueOf(value).setScale(WATERLEVEL_W_MAX_DIGITS, RoundingMode.HALF_EVEN); }