diff --git a/nestkernel/nest_time.cpp b/nestkernel/nest_time.cpp index 668e829372..1cacd2e823 100644 --- a/nestkernel/nest_time.cpp +++ b/nestkernel/nest_time.cpp @@ -176,8 +176,7 @@ Time::fromstamp( Time::ms_stamp t ) // intended ones. tic_t n = static_cast< tic_t >( t.t * Range::TICS_PER_MS ); n -= ( n % Range::TICS_PER_STEP ); - long s = n * Range::TICS_PER_STEP_INV; - double ms = s * Range::MS_PER_STEP; + const double ms = n * Range::TICS_PER_STEP_INV * Range::MS_PER_STEP; if ( ms < t.t ) { n += Range::TICS_PER_STEP; @@ -203,11 +202,11 @@ Time::reset_to_defaults() std::ostream& operator<<( std::ostream& strm, const Time& t ) { - if ( t.tics == Time::LIM_NEG_INF.tics ) + if ( t.is_neg_inf() ) { strm << "-INF"; } - else if ( t.tics == Time::LIM_POS_INF.tics ) + else if ( t.is_pos_inf() ) { strm << "+INF"; } diff --git a/nestkernel/nest_time.h b/nestkernel/nest_time.h index 7fde72d49e..2672f4c8d5 100644 --- a/nestkernel/nest_time.h +++ b/nestkernel/nest_time.h @@ -388,7 +388,22 @@ class Time bool is_neg_inf() const { - return tics == LIM_NEG_INF.tics; + return tics <= LIM_NEG_INF.tics; // currently tics can never + // become smaller than + // LIM_NEG_INF.tics. however if + // LIM_NEG_INF.tics represent + // negative infinity, any smaller + // value cannot be larger and + // thus must be infinity as + // well. to be on the safe side + // we use less-or-equal instead + // of just equal. + } + + bool + is_pos_inf() const + { + return tics >= LIM_POS_INF.tics; // see comment for is_neg_inf() } bool @@ -493,11 +508,11 @@ class Time double get_ms() const { - if ( tics == LIM_POS_INF.tics ) + if ( is_pos_inf() ) { return LIM_POS_INF_ms; } - if ( tics == LIM_NEG_INF.tics ) + if ( is_neg_inf() ) { return LIM_NEG_INF_ms; } @@ -507,11 +522,11 @@ class Time delay get_steps() const { - if ( tics == LIM_POS_INF.tics ) + if ( is_pos_inf() ) { return LIM_POS_INF.steps; } - if ( tics == LIM_NEG_INF.tics ) + if ( is_neg_inf() ) { return LIM_NEG_INF.steps; }