fix overflow problems

in inscribed ellipse algorithm