I created uint8_t and uint16_t variable types and read values into them from some registers. But, I'm unsure if I can easily cast these into float, and if the conversion will make numeric sense.
What is the optimal way to cast uint8_t, and uint16_t, into float?
There's no need to cast; integer types are implicitly convertible to floating-point types.
uint8_t u8 = something;
uint16_t u16 = whatever;
float f1 = u8;
float f2 = u16;
8 and 16-bit integer values should be represented exactly. Larger types might lose some precision.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With