File tree Expand file tree Collapse file tree 2 files changed +6
-6
lines changed
Expand file tree Collapse file tree 2 files changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -469,7 +469,7 @@ Duration& Duration::operator*=(int64_t r) {
469469
470470Duration& Duration::operator *=(double r) {
471471 if (time_internal::IsInfiniteDuration (*this ) || !IsFinite (r)) {
472- const bool is_neg = std::signbit (r) != (rep_hi_.Get () < 0 );
472+ const bool is_neg = std::isnan (r) || std:: signbit (r) != (rep_hi_.Get () < 0 );
473473 return *this = is_neg ? -InfiniteDuration () : InfiniteDuration ();
474474 }
475475 return *this = ScaleDouble<std::multiplies>(*this , r);
@@ -485,7 +485,7 @@ Duration& Duration::operator/=(int64_t r) {
485485
486486Duration& Duration::operator /=(double r) {
487487 if (time_internal::IsInfiniteDuration (*this ) || !IsValidDivisor (r)) {
488- const bool is_neg = std::signbit (r) != (rep_hi_.Get () < 0 );
488+ const bool is_neg = std::isnan (r) || std:: signbit (r) != (rep_hi_.Get () < 0 );
489489 return *this = is_neg ? -InfiniteDuration () : InfiniteDuration ();
490490 }
491491 return *this = ScaleDouble<std::divides>(*this , r);
Original file line number Diff line number Diff line change @@ -841,18 +841,18 @@ TEST(Duration, DivisionByZero) {
841841
842842TEST (Duration, NaN) {
843843 // Note that IEEE 754 does not define the behavior of a nan's sign when it is
844- // copied, so the code below allows for either + or - InfiniteDuration .
844+ // copied. We return -InfiniteDuration in either case .
845845#define TEST_NAN_HANDLING (NAME, NAN ) \
846846 do { \
847847 const auto inf = absl::InfiniteDuration (); \
848848 auto x = NAME (NAN); \
849- EXPECT_TRUE (x == inf || x == -inf); \
849+ EXPECT_TRUE (x == - inf); \
850850 auto y = NAME (42 ); \
851851 y *= NAN; \
852- EXPECT_TRUE (y == inf || y == -inf); \
852+ EXPECT_TRUE (y == - inf); \
853853 auto z = NAME (42 ); \
854854 z /= NAN; \
855- EXPECT_TRUE (z == inf || z == -inf); \
855+ EXPECT_TRUE (z == - inf); \
856856 } while (0 )
857857
858858 const double nan = std::numeric_limits<double >::quiet_NaN ();
You can’t perform that action at this time.
0 commit comments