vendor/bela/src/belatime/duration.cc
inline bool SafeAddRepHi(double a_hi, double b_hi, Duration *d) {
  double c = a_hi + b_hi;
  if (c >= static_cast<double>(kint64max)) {
    *d = InfiniteDuration();
    return false;
  }
  if (c <= static_cast<double>(kint64min)) {
    *d = -InfiniteDuration();
    return false;
  }
  *d = time_internal::MakeDuration(static_cast<int64_t>(c), time_internal::GetRepLo(*d));
  return true;
}
// Note: The overflow detection in this function is done using greater/less *or
// equal* because kint64max/min is too large to be represented exactly in a
// double (which only has 53 bits of precision). In order to avoid assigning to
// rep->hi a double value that is too large for an int64_t (and therefore is
// undefined), we must consider computations that equal kint64max/min as a
// double as overflow cases.
The overflow detection in this function is done using greater/less *or
equal* because kint64max/min is too large to be represented exactly in a
double (which only has 53 bits of precision). In order to avoid assigning to
rep->hi a double value that is too large for an int64_t (and therefore is
undefined), we must consider computations that equal kint64max/min as a
double as overflow cases.
The overflow detection in this function is done using greater / less * or equal * because kint64max / min is too large to be represented exactly in a double ( which only has 53 bits of precision ) . In order to avoid assigning to rep - > hi a double value that is too large for an int64_t ( and therefore is undefined ) we must consider computations that equal kint64max / min as a double as overflow cases .
inline bool SafeAddRepHi(double a_hi, double b_hi, Duration *d) {
  double c = a_hi + b_hi;
  if (c >= static_cast<double>(kint64max)) {
    *d = InfiniteDuration();
    return false;
  }
  if (c <= static_cast<double>(kint64min)) {
    *d = -InfiniteDuration();
    return false;
  }
  *d = time_internal::MakeDuration(static_cast<int64_t>(c), time_internal::GetRepLo(*d));
  return true;
}
inline bool SafeAddRepHi ( double a_hi , double b_hi , Duration * d ) { double c = a_hi + b_hi ; if ( c >= static_cast < double > ( kint64max ) ) { * d = InfiniteDuration ( ) ; return false ; } if ( c <= static_cast < double > ( kint64min ) ) { * d = - InfiniteDuration ( ) ; return false ; } * d = time_internal :: MakeDuration ( static_cast < int64_t > ( c ) , time_internal :: GetRepLo ( * d ) ) ; return true ; }
Note: The overflow detection in this function is done using greater/less *or
equal* because kint64max/min is too large to be represented exactly in a
double (which only has 53 bits of precision).
Note : The overflow detection in this function is done using greater / less * or equal * because kint64max / min is too large to be represented exactly in a double ( which only has 53 bits of precision ) .