Add a cast when converting from double to float

This fixes warnings with MSVC.
Merge pull request #1512 from mstorsjo/add-float-cast

Add a cast when converting from double to float