add degree test, modify divrem for 0 degree