Why this code give to me value "4" instead of "0"?
#define PLUGIN_PPQ 96
#define MIDIENGINE_SCORE_LENGTH PLUGIN_PPQ * 4
int main ()
{
int mCurrentPatternPulse = 97;
int patternBar = (int)floor(mCurrentPatternPulse / MIDIENGINE_SCORE_LENGTH);
cout << "value: " << patternBar << " (" << MIDIENGINE_SCORE_LENGTH << ")";
}
97/384 (with/without floor) should give to me 0.
But it seems it divides by 96 instead of 384? Even if I print MIDIENGINE_SCORE_LENGTH
is 384...
constexpr
variables instead. They will be processed at compile time like the macro but will respect operator precedence because they are variables, and they are known to the language.constexpr
.constexpr
is a suggestion, not an answer to this question