Implemented some very simple math functions to make translation of code from Delphi simpler.