diff --git a/brian2/devices/cpp_standalone/brianlib/clocks.h b/brian2/devices/cpp_standalone/brianlib/clocks.h index b33168304..1617f98f9 100644 --- a/brian2/devices/cpp_standalone/brianlib/clocks.h +++ b/brian2/devices/cpp_standalone/brianlib/clocks.h @@ -19,7 +19,7 @@ class Clock double *dt; int64_t *timestep; double *t; - Clock(double _epsilon=1e-14) : epsilon(_epsilon) { i_end = 0;}; + Clock(double _epsilon=1e-8) : epsilon(_epsilon) { i_end = 0;}; inline void tick() { timestep[0] += 1; @@ -30,18 +30,18 @@ class Clock { int i_start = fround(start/dt[0]); double t_start = i_start*dt[0]; - if(t_start==start || fabs(t_start-start)<=epsilon*fabs(t_start)) + if(t_start==start || fabs(t_start-start)<=epsilon) { timestep[0] = i_start; } else { - timestep[0] = (int)ceil(start/dt[0]); + timestep[0] = (int64_t)ceil(start/dt[0]); } i_end = fround(end/dt[0]); double t_end = i_end*dt[0]; - if(!(t_end==end || fabs(t_end-end)<=epsilon*fabs(t_end))) + if(!(t_end==end || fabs(t_end-end)<=epsilon)) { - i_end = (int)ceil(end/dt[0]); + i_end = (int64_t)ceil(end/dt[0]); } } private: diff --git a/brian2/devices/cpp_standalone/templates/network.cpp b/brian2/devices/cpp_standalone/templates/network.cpp index 197d84696..6179c38dc 100644 --- a/brian2/devices/cpp_standalone/templates/network.cpp +++ b/brian2/devices/cpp_standalone/templates/network.cpp @@ -7,7 +7,7 @@ #include {{ openmp_pragma('include') }} -#define Clock_epsilon 1e-14 +#define Clock_epsilon 1e-8 double Network::_last_run_time = 0.0; double Network::_last_run_completed_fraction = 0.0;