psambit9791 / jdsp

A Java Library for Digital Signal Processing
https://jdsp.dev
MIT License
240 stars 45 forks source link

Rounding error in UtilMethods.round() #3

Closed psambit9791 closed 3 years ago

psambit9791 commented 3 years ago

The round() method under UtilMethods always gives the output in Ceil mode of rounding.

double d1 = 7.40241449;
double d2 = -14.39767505;

System.out.println(UtilMethods.round(d1, 1));
System.out.println(UtilMethods.round(d2, 1));

Outputs: 7.5 , -14.3

Expected: 7.4 , -14.4

psambit9791 commented 3 years ago

Updating RoundingMethod from CEILING to HALF_EVEN.

Fixed.