Fix for cast to float and double

Implemented new version of cast to float
There is an off by one error in float too