Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineCalculator.java @ 9382:8ae7137b67d7
Fixed: avoiding NaN exception in BigDecimal rounding
author | mschaefer |
---|---|
date | Tue, 07 Aug 2018 14:06:49 +0200 |
parents | a0a2e68a1e11 |
children | 439699ff9b2d |
comparison
equal
deleted
inserted
replaced
9381:a9e6b0a75bde | 9382:8ae7137b67d7 |
---|---|
181 | 181 |
182 /** | 182 /** |
183 * Calculates the salix value | 183 * Calculates the salix value |
184 */ | 184 */ |
185 private double calcSalix(final double mhw, final double mw) { | 185 private double calcSalix(final double mhw, final double mw) { |
186 if (Double.isNaN(mw) || Double.isInfinite(mw) || Double.isNaN(mhw) || Double.isInfinite(mhw)) | |
187 return mw; // preserving NaN or Infinity | |
186 return Formatter.roundW(mhw).subtract(SALIX_DISTANCE).subtract(Formatter.roundW(mw)).doubleValue(); | 188 return Formatter.roundW(mhw).subtract(SALIX_DISTANCE).subtract(Formatter.roundW(mw)).doubleValue(); |
187 } | 189 } |
188 | 190 |
189 /** | 191 /** |
190 * Calculates the inverse MW-MNW difference | 192 * Calculates the inverse MW-MNW difference |
191 */ | 193 */ |
192 private double calcMwmnw(final double mw, final double mnw) { | 194 private double calcMwmnw(final double mw, final double mnw) { |
195 if (Double.isNaN(mw) || Double.isInfinite(mw) || Double.isNaN(mnw) || Double.isInfinite(mnw)) | |
196 return mnw - mw; // preserving NaN or Inifinity | |
193 return Formatter.roundW(mnw).subtract(Formatter.roundW(mw)).doubleValue(); | 197 return Formatter.roundW(mnw).subtract(Formatter.roundW(mw)).doubleValue(); |
194 } | 198 } |
195 | 199 |
196 /** | 200 /** |
197 * Gets the station-specific list of delta-ws of the active scenario, at least with one 0 item in any case | 201 * Gets the station-specific list of delta-ws of the active scenario, at least with one 0 item in any case |