forked from upstream-mirrors/OpenTracks
Bug fix, use Math.round to convert double to long
This commit is contained in:
+2
-2
@@ -248,8 +248,8 @@ public class AnnouncementPeriodicTask implements PeriodicTask {
|
||||
} else {
|
||||
speed = speed == 0 ? 0.0 : 1 / speed;
|
||||
int paceId = metricUnits ? R.string.voice_pace_per_kilometer : R.string.voice_pace_per_mile;
|
||||
long time = (long) (speed * UnitConversions.HR_TO_MIN * UnitConversions.MIN_TO_S
|
||||
* UnitConversions.S_TO_MS);
|
||||
long time = Math.round(
|
||||
speed * UnitConversions.HR_TO_MIN * UnitConversions.MIN_TO_S * UnitConversions.S_TO_MS);
|
||||
rate = context.getString(paceId, getAnnounceTime(time));
|
||||
}
|
||||
|
||||
|
||||
@@ -314,7 +314,7 @@ public class StringUtils {
|
||||
if (fractional != null) {
|
||||
// Regex ensures fractional part is in (0,1)
|
||||
float fractionalSeconds = Float.parseFloat(fractional);
|
||||
long fractionalMillis = (long) (fractionalSeconds * UnitConversions.S_TO_MS);
|
||||
long fractionalMillis = Math.round(fractionalSeconds * UnitConversions.S_TO_MS);
|
||||
time += fractionalMillis;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user