How's it going?
I have a hopefully-simple scenario involving typecasting.
Here's what I have:
double input = myCooler.getInput(); int conversion = (int)input; uint8_t conv = (uint8_t)conversion; SPDR = conv;
myCooler.getInput() is just a function that returns a double.
The SPDR register on my Arduino holds unsigned 8 bit integers at the minimum (and, conveniently, is all I need for my project.)
Can I write the above code like this instead, or is it bad practice? (Mind you, I don't need those variables after that chunk of code executes.)
SPDR = (uint8_t)((int)myCooler.getInput());