16 #ifndef __OMNETPP_SIMTIMEMATH_H 17 #define __OMNETPP_SIMTIMEMATH_H 24 inline int64_t _i64mod(
const int64_t& any_t,
const int64_t& positive_u)
26 int64_t m = any_t % positive_u;
27 return m>=0 ? m : m+positive_u;
33 inline const SimTime floor(
const SimTime& x)
37 return SimTime().setRaw(t - _i64mod(t,u));
47 inline const SimTime floor(
const SimTime& x,
const SimTime& unit,
const SimTime& offset = SimTime())
49 int64_t off = offset.
raw();
50 int64_t u = unit.raw();
51 int64_t t = x.raw() - off;
52 return SimTime().setRaw(t - _i64mod(t,u) + off);
58 inline const SimTime ceil(
const SimTime& x)
61 int64_t t = x.raw() + u-1;
62 return SimTime().setRaw(t - _i64mod(t,u));
69 inline const SimTime ceil(
const SimTime& x,
const SimTime& unit,
const SimTime& offset = SimTime())
71 int64_t off = offset.
raw();
72 int64_t u = unit.raw();
73 int64_t t = x.raw() - off + u-1;
74 return SimTime().setRaw(t - _i64mod(t,u) + off);
80 inline const SimTime fabs(
const SimTime& x)
82 return x.
raw()<0 ? -x : x;
95 inline int64_t div(
const SimTime& x,
const SimTime& y)
97 return x.raw() / y.raw();
115 inline const SimTime fmod(
const SimTime& x,
const SimTime& y)
117 return SimTime().
setRaw(x.raw() % y.raw());
129 SIM_API int64_t preciseDiv(int64_t x,
const SimTime& y, int64_t& fractionNumerator, int64_t& fractionDenominator);
int64_t raw() const
Definition: simtime.h:381
const SimTime & setRaw(int64_t l)
Definition: simtime.h:391
Definition: cabstracthistogram.h:21
static int64_t getScale()
Definition: simtime.h:403