Strange integer behavior

I'm using an Arduino UNO and having some odd behavior with multiplying integers.

int timer_duration_ms = 2 * 60 * 1000;
Serial.println(timer_duration_ms);

Outputs "-11072"!

Any idea what I'm doing wrong?

unsigned long timer_duration_ms = 2 * 60 * 1000UL;

Any idea what I'm doing wrong?

You're trying to squeeze a quart into a pint pot.

TheMemberFormerlyKnownAsAWOL:
You're trying to squeeze a quart into a pint pot.

16.87 bits into a 16-bit variable. 15 bit, is you take sign into account.

Arduino data types.

wrybread:
I'm using an Arduino UNO and having some odd behavior with multiplying integers.

int timer_duration_ms = 2 * 60 * 1000;
Serial.println(timer_duration_ms);

Outputs "-11072"!

Any idea what I'm doing wrong?

On the platform you are using, 'int' can hold values from -32768 to +32767. Your calculation overflows, and you end up with junk.

Try using 'long int' instead. It can hold values from about -2 billion to + 2 billion.