fix error masked by wrong call to integer abs (should have been std::abs)