Use static_cast to remove warnings in Visual C++

Use static_cast to convert int into float and vice versa.