Saturday, May 15, 2010

Integer cast order of operations

Using the Arduino integer types:
byte moo = 166;
int  pok = 500;

This doesn't work:
long cat = moo*pok;

This works:
long cat = (long) moo*pok;

But only because the default order of operations makes it:
long cat = ((long) moo) * pok;

No comments:

Post a Comment