comparison artifacts/src/main/java/org/dive4elements/river/utils/Formatter.java @ 9367:8aa1605e58f1

Fixed: rounding methods NaN aware in Formatter
author mschaefer
date Thu, 02 Aug 2018 16:08:51 +0200
parents 2aec052d4088
children a0a2e68a1e11
comparison
equal deleted inserted replaced
9366:3d006afee054 9367:8aa1605e58f1
384 public static NumberFormat getFlowDepth(final CallContext context) { 384 public static NumberFormat getFlowDepth(final CallContext context) {
385 return Formatter.getFormatter(context, FLOWDEPTH_MAX_DIGITS, FLOWDEPTH_MAX_DIGITS); 385 return Formatter.getFormatter(context, FLOWDEPTH_MAX_DIGITS, FLOWDEPTH_MAX_DIGITS);
386 } 386 }
387 387
388 public static double roundFlowDepth(final double value) { 388 public static double roundFlowDepth(final double value) {
389 if (Double.isNaN(value))
390 return Double.NaN;
389 return Math.round(value * FLOWDEPTH_ROUND_MULT) / FLOWDEPTH_ROUND_MULT; 391 return Math.round(value * FLOWDEPTH_ROUND_MULT) / FLOWDEPTH_ROUND_MULT;
390 } 392 }
391 393
392 public static NumberFormat getW(final CallContext context) { 394 public static NumberFormat getW(final CallContext context) {
393 return Formatter.getFormatter(context, 2, 2); 395 return Formatter.getFormatter(context, 2, 2);
394 } 396 }
395 397
396 public static double roundW(final double value) { 398 public static double roundW(final double value) {
399 if (Double.isNaN(value))
400 return Double.NaN;
397 return Math.round(value * W_ROUND_MULT) / W_ROUND_MULT; 401 return Math.round(value * W_ROUND_MULT) / W_ROUND_MULT;
398 } 402 }
399 403
400 /** 404 /**
401 * Another waterlevel formatter with fixed digits (always 2) 405 * Another waterlevel formatter with fixed digits (always 2)

http://dive4elements.wald.intevation.org