refactored modules/core/src/arithm.cpp