When assigning values for variables that hold floating points numbers like floats or vectors, is it necessary to specify the value as float or double, or is it enough to use integer literals? I’ve seen a lot of code where the value is assigned explicitly with floating-point literals
float var = 10.0, instead of using shorter integer literals
float var = 10. But is the later legal and will it cause any issues?
What about when performing arithmetic operations can we use integer literals
float var2 = var+10 instead of
float var2 = var+10.0?