Functions from <algorithm> reimplemented in libuavcan

This commit is contained in:
Pavel Kirienko
2014-05-04 23:13:38 +04:00
parent cf3d6e2c08
commit 7608e4ca08
19 changed files with 152 additions and 46 deletions
+3 -3
View File
@@ -42,7 +42,7 @@ public:
int64_t toUSec() const { return usec_; }
int64_t toMSec() const { return usec_ / 1000; }
D getAbs() const { return D::fromUSec(std::abs(usec_)); }
D getAbs() const { return D::fromUSec((usec_ < 0) ? (-usec_) : usec_); }
bool isPositive() const { return usec_ > 0; }
bool isNegative() const { return usec_ < 0; }
@@ -229,8 +229,8 @@ void DurationBase<D>::toString(char buf[StringBufSize]) const
*ptr++ = '-';
}
(void)snprintf(ptr, StringBufSize - 1, "%llu.%06lu",
static_cast<unsigned long long>(std::abs(toUSec() / 1000000L)),
static_cast<unsigned long>(std::abs(toUSec() % 1000000L)));
static_cast<unsigned long long>(getAbs().toUSec() / 1000000L),
static_cast<unsigned long>(getAbs().toUSec() % 1000000L));
}