Hi, I think that your code is very helpful. However, I found a minor bug in the code.
if bitshift(error,1) >= delx, % same as -> if 2*error >= delx,
y_n = y_n + ystep;
error = error - delx;
In case of a coordinate of first point is (2,3) and second point is (3,11), it does not work and print out error message. I think this error caused by 'bitshift' function. I changed the function to '2*error', then the problem is solved.