Fix narrowing-conversion issues by using std::fabs instead of fabs.