Skip to content

Commit

Permalink
abs to ui64 function has been added
Browse files Browse the repository at this point in the history
  • Loading branch information
dorooleg committed May 21, 2024
1 parent 148c858 commit 38d1aee
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,18 @@ bool IsOverflow(ui64 a, ui64 b) {
return b > diff;
}

ui64 AbsToUi64(i64 value) {
if (value >= 0) {
return value;
}
if (value == std::numeric_limits<i64>::min()) {
return (ui64)std::numeric_limits<i64>::max() + 1;
}
return -value;
}

bool IsOverflowUi64I64(ui64 a, i64 b) {
return b > 0 ? IsOverflow(a, (ui64)b) : a < (ui64)-b;
return b > 0 ? IsOverflow(a, (ui64)b) : a < AbsToUi64(b);
}

TDuration FromUnit(int64_t interval, IPathGenerator::EIntervalUnit unit) {
Expand Down

0 comments on commit 38d1aee

Please sign in to comment.