[NEURE-330] Rounding milliseconds to seconds unexpected behaviour Created: 12/Dec/2014 Updated: 15/Dec/2014 Resolved: 15/Dec/2014 |
|
| Status: | Closed |
| Project: | NEURE |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | 1.7.0 |
| Type: | Bug | Priority: | Minor |
| Reporter: | Juho Tammela | Assignee: | Juho Tammela |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Description |
|
Rounding to seconds in NeureSeries method getElapsedTimeSeconds not rounding as expected, for example 3449 milliseconds is rounded to 3.4 seconds. |
| Comments |
| Comment by Oleksandr Maslov [ 15/Dec/2014 ] |
|
Seems like it is. And it mentioned in So using BigDecimal.valueOf(3445 / 1000.0) is totally different |
| Comment by Juho Tammela [ 15/Dec/2014 ] |
|
Even with scale set to 2 there's problems for example rounding 3445 results in 3.44. It seems the problem here is constructing the BigDecimal from a double as suggested in http://stackoverflow.com/questions/12460482/how-to-round-0-745-to-0-75-using-bigdecimal-round-half-up |
| Comment by Oleksandr Maslov [ 13/Dec/2014 ] |
|
there is setScale(1, RoundingMode.HALP_UP). I think it works like expected. That 1 in setScale is the reason you get 3.4 with 2 it would be 3.45 |