#ifndef COMPLIB_SERVER_MATHUTILS_HPP
#define COMPLIB_SERVER_MATHUTILS_HPP

#include <cstdint>

namespace mathUtils {
    inline int int_from_bytes(uint8_t *data, int length) {
        int ret = 0;

        int i = 0;
        for (int j = length -1; j >= 0; j--) {
            ret = ret | (data[i] << (j * 8));
            i++;
        }
        return ret;
    }

    inline void bytes_from_int(int data, int length, uint8_t *result) {
        int i = 0;
        for (int j = length -1; j >= 0; j--) {
            result[i] = ((data >> (j * 8)) & 0xffu);
            i++;
        }
    }
}

#endif // COMPLIB_SERVER_MATHUTILS_HPP