I am reading the docs on DigitalRead() and wondering why it stores seemingly boolean HIGH
and LOW
inputs in int
data type variable.
I have two issues with that:
int
is 2-byte, whilebool
anduint8_t
are 1-byte so it seems like a waste of memory for no benefit whatsoever.- It gets me confused when reading the code about whether the input came from digital or analog since
int
can have a wide range.
Is there any particular reason for storing digital inputs as int
?
EDIT: bool
and uint8_t
are out of the question as per the answer below. int8_t
still looks suitable for the purpose though.
uint8_t
.