Bug 1222866: P1. Round second to closest microseconds. r=gerald.

Due to the internal double representation as per IEEE 754, during conversion the use of ints would have rounded down our value.
This commit is contained in:
Jean-Yves Avenard 2015-11-20 11:06:22 +11:00
Родитель 16757f4a4b
Коммит 7c8d6ceb7d
1 изменённых файлов: 3 добавлений и 1 удалений

Просмотреть файл

@ -93,7 +93,9 @@ public:
if (mozilla::IsInfinite<double>(aValue)) {
return FromInfinity();
}
double val = aValue * USECS_PER_S;
// Due to internal double representation, this
// operation is not commutative, do not attempt to simplify.
double val = (aValue + .0000005) * USECS_PER_S;
if (val >= double(INT64_MAX)) {
return FromMicroseconds(INT64_MAX);
} else if (val <= double(INT64_MIN)) {