Resolve some MS compiler warnings (in picky mode)

warning C4267: 'argument' : conversion from 'size_t' to 'DWORD', possible loss of data
warning C4244: 'return' : conversion from 'double' to 'int', possible loss of data