millis()
returns a unsigned long
, which is a 32-bit unsigned integer on the Arduino. When you then try to do something like unsigned int time = millis() - 1000
, you try to store that in a 16-bit unsigned integer unsigned int
. A 16-bit integer can never hold a 32-bit value.
According to the C specification, paragraph 6.3.1.3, the upper 16 bits are discarded.
If possible, keep the millis()
output in a unsigned long
and only use data types with less bits when you're absolutely sure you will not lose bits.
There's more information on explicit casts in C here: http://stackoverflow.com/a/13652624/1544337 https://stackoverflow.com/a/13652624/1544337
millis()
returns a unsigned long
, which is a 32-bit unsigned integer on the Arduino. When you then try to do something like unsigned int time = millis() - 1000
, you try to store that in a 16-bit unsigned integer unsigned int
. A 16-bit integer can never hold a 32-bit value.
According to the C specification, paragraph 6.3.1.3, the upper 16 bits are discarded.
If possible, keep the millis()
output in a unsigned long
and only use data types with less bits when you're absolutely sure you will not lose bits.
There's more information on explicit casts in C here: http://stackoverflow.com/a/13652624/1544337
millis()
returns a unsigned long
, which is a 32-bit unsigned integer on the Arduino. When you then try to do something like unsigned int time = millis() - 1000
, you try to store that in a 16-bit unsigned integer unsigned int
. A 16-bit integer can never hold a 32-bit value.
According to the C specification, paragraph 6.3.1.3, the upper 16 bits are discarded.
If possible, keep the millis()
output in a unsigned long
and only use data types with less bits when you're absolutely sure you will not lose bits.
There's more information on explicit casts in C here: https://stackoverflow.com/a/13652624/1544337
millis()
returns a unsigned long
, which is a 32-bit unsigned integer on the Arduino. When you then try to do something like unsigned int time = millis() - 1000
, you try to store that in a 16-bit unsigned integer unsigned int
. A 16-bit integer can never hold a 32-bit value.
According to the C specification the exact behaviour is implementation-defined, meaning anything may happen (and the exact behaviour is -hopefully- documented somewhere deep down in the Arduino docs)C specification , paragraph 6. What normally happens is that3.1.3, the upper 16 bits are discarded, but you can't rely on that.
If possible, keep the millis()
output in a unsigned long
and only use data types with less bits when you're absolutely sure you will not lose bits.
There's more information on explicit casts in C here: http://stackoverflow.com/a/13652624/1544337
millis()
returns a unsigned long
, which is a 32-bit unsigned integer on the Arduino. When you then try to do something like unsigned int time = millis() - 1000
, you try to store that in a 16-bit unsigned integer unsigned int
. A 16-bit integer can never hold a 32-bit value.
According to the C specification the exact behaviour is implementation-defined, meaning anything may happen (and the exact behaviour is -hopefully- documented somewhere deep down in the Arduino docs). What normally happens is that the upper 16 bits are discarded, but you can't rely on that.
If possible, keep the millis()
output in a unsigned long
and only use data types with less bits when you're absolutely sure you will not lose bits.
There's more information on explicit casts in C here: http://stackoverflow.com/a/13652624/1544337
millis()
returns a unsigned long
, which is a 32-bit unsigned integer on the Arduino. When you then try to do something like unsigned int time = millis() - 1000
, you try to store that in a 16-bit unsigned integer unsigned int
. A 16-bit integer can never hold a 32-bit value.
According to the C specification , paragraph 6.3.1.3, the upper 16 bits are discarded.
If possible, keep the millis()
output in a unsigned long
and only use data types with less bits when you're absolutely sure you will not lose bits.
There's more information on explicit casts in C here: http://stackoverflow.com/a/13652624/1544337
millis()
returns a unsigned long
, which is a 32-bit unsigned integer on the Arduino. When you then try to do something like unsigned int time = millis() - 1000
, you try to store that in a 16-bit unsigned integer unsigned int
. A 16-bit integer can never hold a 32-bit value.
According to the C specification the exact behaviour is implementation-defined, meaning anything may happen (and the exact behaviour is -hopefully- documented somewhere deep down in the Arduino docs). What normally happens is that the upper 16 bits are discarded, but you can't rely on that.
If possible, keep the millis()
output in a unsigned long
and only use data types with less bits when you're absolutely sure you will not lose bits.
There's more information on explicit casts in C here: http://stackoverflow.com/a/13652624/1544337
millis()
returns a unsigned long
, which is a 32-bit unsigned integer on the Arduino. When you then try to do something like int time = millis() - 1000
, you try to store that in a 16-bit integer int
. A 16-bit integer can never hold a 32-bit value.
According to the C specification the exact behaviour is implementation-defined, meaning anything may happen (and the exact behaviour is -hopefully- documented somewhere deep down in the Arduino docs). What normally happens is that the upper 16 bits are discarded, but you can't rely on that.
If possible, keep the millis()
output in a unsigned long
and only use data types with less bits when you're absolutely sure you will not lose bits.
There's more information on explicit casts in C here: http://stackoverflow.com/a/13652624/1544337
millis()
returns a unsigned long
, which is a 32-bit unsigned integer on the Arduino. When you then try to do something like unsigned int time = millis() - 1000
, you try to store that in a 16-bit unsigned integer unsigned int
. A 16-bit integer can never hold a 32-bit value.
According to the C specification the exact behaviour is implementation-defined, meaning anything may happen (and the exact behaviour is -hopefully- documented somewhere deep down in the Arduino docs). What normally happens is that the upper 16 bits are discarded, but you can't rely on that.
If possible, keep the millis()
output in a unsigned long
and only use data types with less bits when you're absolutely sure you will not lose bits.
There's more information on explicit casts in C here: http://stackoverflow.com/a/13652624/1544337