Multiplying within #define gives strange values

  arduino, c++

I write a code for Arduino Nano and I experience this weird behaviour:

#define     GREAT      (60 * 60000)
#define     STRANGE     (60 * 6000)
#define     ZERO_X      (60 * 1000)

void setup() {
    Serial.begin(115200);
    Serial.println(GREAT);      // Prints 3600000, that's correct
    Serial.println(STRANGE);    // Prints 32320, thats wrong
    long zerox = ZERO_X;
    Serial.println(zerox);      // Prints -5536, thats also wrong, obviously
}

void loop() {}

What is going on?

I use MSVS2019 Comunity with vMicro

Source: Windows Questions C++

LEAVE A COMMENT