I am creating a small Android app in which I am doing some math calculation, using both Java and SQLite. The issue is that the SQLite function round(...) return different value than Java Math.round(..) in some devices.
To be more precise, my goal is to round double numbers to two decimal places, In Java I used this method:
public static double round2(double value){
value= Math.round(value* 100.0) / 100.0;
return value;
}
in SQLite my query is : SELECT ROUND(total, 2)
running the above code, the obtained result are as follow:
in Java rounding 66.875 return 66.88
For the SQL query, in some Android device, the result is 66.88 (Android API 28) , while it is 66.87 in others (API 24).
Anyone has encounter the same situation, please i want to find a way to obtain same rounding in Java and SQLite in all devices whatever the device API is.