int / float
Greetings,
short question:
|
a = static_cast<float>(150-i*i)/10.0f
|
a is a float, i is an int.
Why is static_cast necessary? I divide integers by a float, shouldn't this automatically lead to a float value?
Regards
Why is static_cast necessary? |
Well in this case the explicit cast is not needed but it does help show intent and it is not wrong to avoid implicit casts.
By the way why are you using float instead of double?
Thank you jlb,
I am not using anything, it's from a book :)
Topic archived. No new replies allowed.