MCPcopy Create free account
hub / github.com/RcppCore/Rcpp / increment_overflow

Function increment_overflow

src/date.cpp:452–465  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

450 */
451
452 static int increment_overflow(int *const ip, int j) {
453 int const i = *ip;
454
455 /*
456 ** If i >= 0 there can only be overflow if i + j > INT_MAX
457 ** or if j > INT_MAX - i; given i >= 0, INT_MAX - i cannot overflow.
458 ** If i < 0 there can only be overflow if i + j < INT_MIN
459 ** or if j < INT_MIN - i; given i < 0, INT_MIN - i cannot overflow.
460 */
461 if ((i >= 0) ? (j > INT_MAX - i) : (j < INT_MIN - i))
462 return TRUE; // #nocov
463 *ip += j;
464 return FALSE;
465 }
466
467 static int increment_overflow_time(time_t *tp, int_fast32_t j) { // #nocov start
468 /*

Callers 1

timesubFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected