As Arduino is C++, you should really use a static cast, to be technically accurate. However, for Arduino code it probably doesn't really matter.
float f = static_cast< float >(i) / static_cast< float >(j);
float f = static_cast< float >(i) / j;
Note: Using a static cast on each operand, rather than just one, is useful to quiet any warnings about the loss of precision with
float, which typically needs to form a rounded
float for large
See C++ int float casting for more info.
Just to add to Jot's answer: Strictly speaking, it should be pointed out that
(float) is C, whereas
float() is C++.
Also, as you had meant to write in your question:
int i = 6312;
int j = 258;
f = i;
f = f/j;
Yes, that would work. However, even though it seems quite elegant, it could cause confusion later in time, when someone else examines the code - unless you added a comment explaining why.
it is probably best to keep the code simple and obvious (for debugging purposes) unless you are deliberately intending to obfuscate the code.