0

double installedChannels[16][3] = {{1,868.1},{1,868.3},{1,868.5},{2,863.0}};

//and installedChannels[x][2] is dynamically changing with value of current time

if (installedChannels[i][2] <= simTime().dbl()) { //do so and so. however sometime current simTime is equal to value stored in installedChannels[i][2] //yet it never gets in this loop }

  • Too little info. Please post a [mcve]. – Jesper Juhl Nov 14 '17 at 21:03
  • be warned that even if two `double`s seem equal, they may not be... see the `0.1 + 0.2 != 0.3` [problem](https://stackoverflow.com/questions/588004/is-floating-point-math-broken) – kmdreko Nov 14 '17 at 21:11

1 Answers1

3

Did you check the comments for OMNeT's simtime dbl() function?

/**
 * Converts simulation time (in seconds) to a double. Note that conversion to
 * and from double may lose precision. We do not provide implicit conversion
 * to double as it would conflict with other overloaded operators, and would
 * cause ambiguities during compilation.
 */

This loss of precision might be the case why comparisons against a value might not work. If you want exact value comparisons, you need to use the simtime_t type (eventually the SimTime class).

Did you also check that your if-condition is actually checked at times where the entering into the loop is actually possible (does the if X == TRUE case actually occur)?

Michael Kirsche
  • 901
  • 7
  • 14