You add a cast to double at many places. Why this is needed? Microsoft compiler won't support the c++ interface of those functions?