msvc9 compatibility

- sqrt in msvc9 needs explicit cast from int
- freak error with cuda & msvc9 when using modulus operator(%)
extra explanation in code
Merge pull request #460 from bbudescu/msvc9-compat

msvc9 compatibility