There's obviously some issues involving casting, but some of these look weird. Try it using 1.0 (or 1. too, but I doubt that makes a speed difference.)