move math functions from msb-js