-->
Page 5 of 5

Re: Power usage

PostPosted: Tue Aug 04, 2015 9:48 am
by martinayotte
LauBaz wrote:ESP.deepSleep(60*60*1000000); //Compiler error: "warning: integer overflow in expression [-Woverflow]"
ESP.deepSleep(3600000000); //no error, this seems to work (although I have not waited an hour to wait for it). I have even tried it all the way to 4294967295 (2^32 -1) and it compiles fine.

What am I missing there?

Simply that last bit of int or long is the +/- sign, so number part is 31 bits not 32 bits. If you cast them to "unsigned int", you won't get the warning.

Re: Power usage

PostPosted: Tue Aug 04, 2015 10:49 am
by LauBaz
martinayotte wrote:
Simply that last bit of int or long is the +/- sign, so number part is 31 bits not 32 bits. If you cast them to "unsigned int", you won't get the warning.


Ah! Excellent point, thank you. I fixed it by doing the following, forcing an unsigned int to my operation:

ESP.deepSleep(60U*60*1000000); //U for unsigned int