Electrical Engineering Asked on November 23, 2021
In computers, it’s OK to use float
as an argument where the argument should actually be a uint8_t
void myFunction(uint8_t myVal);
But what if I call this function myFunction(value);
where value
is of datatype float
inside a microcontroller? The microcontroller have single precision included. The variable value
have its range from 0 to 250 in this case.
Do I need to call my function myFunction((uint8_t) value)
?
No need to do explicit cast, the compiler knows what to do implicitly, just like when you assign the float to an integer variable for example.
Answered by Justme on November 23, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP