Commit e9095643 authored by Bruce Dawson's avatar Bruce Dawson Committed by Commit Bot

Add an explicit cast from int64_t to double

A double cannot hold all of the values that an int64_t can hold, and
this is certainly true for the max() and min() values. Adding a cast
suppresses a new VC++ warning and makes it explicit that some rounding
is going on.

Change-Id: I8373f6784360a0c71ed3f27fc21aec4bc8c1e77f
Reviewed-on: https://chromium-review.googlesource.com/1053730
Commit-Queue: Yuri Wiitala <miu@chromium.org>
Reviewed-by: default avatarYuri Wiitala <miu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#558838}
parent 6b0b0c26
...@@ -1291,8 +1291,10 @@ TEST(TimeDelta, MaxConversions) { ...@@ -1291,8 +1291,10 @@ TEST(TimeDelta, MaxConversions) {
EXPECT_TRUE(TimeDelta::FromSecondsD(std::numeric_limits<double>::infinity()) EXPECT_TRUE(TimeDelta::FromSecondsD(std::numeric_limits<double>::infinity())
.is_max()); .is_max());
constexpr double max_d = max_int; // Note that max_int/min_int will be rounded when converted to doubles - they
constexpr double min_d = min_int; // can't be exactly represented.
constexpr double max_d = static_cast<double>(max_int);
constexpr double min_d = static_cast<double>(min_int);
static_assert( static_assert(
TimeDelta::FromSecondsD(max_d / Time::kMicrosecondsPerSecond + 1) TimeDelta::FromSecondsD(max_d / Time::kMicrosecondsPerSecond + 1)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment