I'm using code that casts some ints to floats for division.
size_t a;
uint8_t b, c;
a = (float)b / (float)c;
I was compiling with warning flags enabled and I got one for 'old cast'. Is there a better or proper way I should be casting these things? If so, how?
Old style casts are "C-style" casts.
-Werror=old-style-cast
turns the usage of C-style casts into errors.
You should use the C++ casts.
Here you can use a static_cast
:
size_t a; uint8_t b, c;
a = static_cast<float>(b) / static_cast<float>(c);
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