AndroidAPS/app/src/main/java/info/nightscout/utils/Round.java

26 lines
587 B
Java
Raw Normal View History

2016-06-20 12:03:05 +02:00
package info.nightscout.utils;
/**
* Created by mike on 20.06.2016.
*/
public class Round {
2017-06-15 22:55:07 +02:00
public static Double roundTo(double x, Double step) {
2016-06-20 12:03:05 +02:00
if (x != 0d) {
return Math.round(x / step) * step;
}
return 0d;
}
2016-06-20 20:45:55 +02:00
public static Double floorTo(Double x, Double step) {
if (x != 0d) {
return Math.floor(x / step) * step;
}
return 0d;
}
public static Double ceilTo(Double x, Double step) {
if (x != 0d) {
return Math.ceil(x / step) * step;
}
return 0d;
}
2016-06-20 12:03:05 +02:00
}