\makeatletter
\op@split{0}{@zero}
\op@split{1}{@one}
\op@split{2}{@two}
\op@split{3}{@three}
\op@split{4}{@four}
\op@split{5}{@five}
\op@split{6}{@six}
\op@split{7}{@seven}
\op@split{8}{@height}
\op@split{9}{@nine}
\op@split{10}{@ten}

\newcommand \opsqrt[3][nil]
{%
  \begingroup
  \opset{#1}%
  \opcmp{0}{#2}%
  \ifopeq
    \op@copy{@zero}{U}%
    \let\op@savemaxdivstep\op@maxdivstep
  \else
    \op@split{#2}{z}%
    \count@=\OP@z@i
    \divide\count@ by2
    \edef\op@savemaxdivstep{\op@maxdivstep}%
    \count@i=\op@maxdivstep
    \advance\count@i by\count@
    \advance\count@i by1
    \edef\op@maxdivstep{\the\count@i}%
    \ifodd\OP@z@i
      \xdef\op@initsqrt{\@nameuse{OP@z@\OP@z@w}}%
    \else
      \count@=\OP@z@w
      \xdef\op@initsqrt{\@nameuse{OP@z@\the\count@}}%
      \advance\count@ by-1
      \xdef\op@initsqrt{\op@initsqrt\@nameuse{OP@z@\the\count@}}%
    \fi
    \ifnum\op@initsqrt<1
      \op@copy{@zero}{u}%
    \else\ifnum\op@initsqrt<3
      \op@copy{@one}{u}%
    \else\ifnum\op@initsqrt<7
      \op@copy{@two}{u}%
    \else\ifnum\op@initsqrt<13
      \op@copy{@three}{u}%
    \else\ifnum\op@initsqrt<21
      \op@copy{@four}{u}%
    \else\ifnum\op@initsqrt<31
      \op@copy{@five}{u}%
    \else\ifnum\op@initsqrt<43
      \op@copy{@six}{u}%
    \else\ifnum\op@initsqrt<57
      \op@copy{@seven}{u}%
    \else\ifnum\op@initsqrt<73
      \op@copy{@height}{u}%
    \else\ifnum\op@initsqrt<91
      \op@copy{@nine}{u}%
    \else
      \op@copy{@ten}{u}%
    \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
    \count@ii=\OP@z@i
    \advance\count@ii by1
    \divide\count@ii by2
    \advance\count@ii by-1
    \op@lshift{\the\count@ii}{u}%
    \count@=\OP@z@w
    \advance\count@ by1
    \edef\op@@maxdivstep{\op@maxdivstep}%
    \loop
      \op@mul{u}{u}{U}%
      \op@add{U}{z}{U}%
      \op@mul{u}{@two}{D}%
      \edef\op@maxdivstep{\the\count@}%
      \op@div{0}{U}{D}{U}{r}%
      \multiply\count@ by2
      \ifnum\count@>\op@@maxdivstep
        \count@=\op@@maxdivstep
      \fi
      \op@cmp{u}{U}%
    \ifopneq
      \op@copy{U}{u}%
    \repeat
  \fi
  \op@unsplit{U}{#3}%
  \opround{#3}{\op@savemaxdivstep}{#3}%
  \endgroup
}

\newcommand \opgfsqrt[2][nil]{%
  \begingroup
  \edef\op@saveparindent{\the\parindent}%
  \parindent=0pt
  \opset{#1}%
  \op@split{#2}{sq}%
  \opsqrt{#2}{@sqrt}%
  \op@split{@sqrt}{sqrt}%
  \op@split{\op@initsqrt}{init}%
  \count@=\OP@sqrt@w
  \op@split{\@nameuse{OP@sqrt@\the\count@}}{atosub}%
  \op@mul{atosub}{atosub}{tosub}%
  \setbox1=\hbox{\kern\opcolumnwidth
    \op@display{operandstyle.1}{sq}}%
  \setbox2=\vtop{%
    \hbox{\ophline(-0.5,-0.25){\OP@sqrt@w.5}%
      \op@display{resultstyle}{sqrt}}%
    \hbox{\op@display{intermediarystyle.1}{atosub}%
      \hbox to\opcolumnwidth{\hss\op@mulsymbol\hss}%
      \op@display{intermediarystyle.1}{atosub}%
      \hbox to\opcolumnwidth{\hss\op@equalsymbol\hss}%
      \op@display{operandstyle.2}{tosub}}%
  }
  \op@sub{init}{tosub}{rest}%
  \count@ii=\OP@init@w
  \count@iii=\count@ii
  \advance\count@iii by1
  \setbox1=\hbox{\hsize=\count@iii\opcolumnwidth\vtop{%
      \box1
      \hbox{%
        \op@makebox{\the\count@iii}{0}%
        {operandstyle.2}{tosub}%
        \box0}}}%
  \op@unzero{rest}%
  \op@copy{@zero}{cursqrt}%
  \op@copy{@zero}{digitmul}%
  \count@i=\OP@sq@w
  \advance\count@i by-\OP@init@w
  \count@iv=2
  \loop
  \ifnum\count@>1
    \op@lshift{2}{rest}%
    \ifnum\count@i>0 % here!
      \@namexdef{OP@rest@2}{\@nameuse{OP@sq@\the\count@i}}%
      \advance\count@i by-1
      \ifnum\count@i>0 % here!
        \@namexdef{OP@rest@1}{\@nameuse{OP@sq@\the\count@i}}%
        \advance\count@i by-1
      \fi
    \fi
    \count@ii=\count@iii
    \advance\count@ii by-\OP@tosub@w
    \advance\count@ii by-1
    \advance\count@iii by2
    \setbox1=\hbox{\hsize=\count@iii\opcolumnwidth
      \vtop{%
        \hbox{\box1}%
        \hbox{%
          \oplput(\count@ii,0.75){\ophline(0,0){1}}%
          \oplput(\count@ii,0.75){\ophline(1,0){\OP@tosub@w}}%
          \advance\count@iv by-1
          \op@makebox{\the\count@iii}{0}%
          {remainderstyle.\the\count@iv}{rest}%
          \advance\count@iv by1
          \oplput(\count@ii,1.5){$-$}%
          \box0}%
      }}%
    \op@multen{cursqrt}%
    \@namexdef{OP@cursqrt@1}%
    {\@nameuse{OP@sqrt@\the\count@}}%
    \advance\count@ by-1
    \op@mul{cursqrt}{@two}{atosub}%
    \op@unzero{atosub}%
    \op@multen{atosub}%
    \@namexdef{OP@atosub@1}%
    {\@nameuse{OP@sqrt@\the\count@}}%
    \@namexdef{OP@digitmul@1}%
    {\@nameuse{OP@sqrt@\the\count@}}%
    \op@mul{atosub}{digitmul}{tosub}%
    \op@unzero{tosub}%
    \setbox2=\hbox{\vtop{%
        \hbox{\box2}%
        \hbox{\vrule width0pt height0pt
          depth\oplineheight}%
        \hbox{%
          \op@display
          {intermediarystyle.\the\count@iv}{atosub}%
          \hbox to\opcolumnwidth{\hss\op@mulsymbol\hss}%
          \op@display
          {intermediarystyle.\the\count@iv}{digitmul}%
          \hbox to\opcolumnwidth{\hss\op@equalsymbol\hss}%
          \advance\count@iv by1
          \op@display{operandstyle.\the\count@iv}{tosub}%
        }%
      }}%
    \op@sub{rest}{tosub}{rest}%
    \op@unzero{rest}%
    \advance\count@iv by1
    \setbox1=\hbox{\hsize=\count@iii\opcolumnwidth
      \vtop{%
        \hbox{\box1}%
        \hbox{%
          \op@makebox{\the\count@iii}{0}%
          {operandstyle.\the\count@iv}{tosub}%
          \box0}}}%
    \repeat
    \count@ii=\count@iii
    \advance\count@ii by-\OP@tosub@w
    \advance\count@ii by-1
    \setbox1=\hbox{\hsize=\count@iii\opcolumnwidth
      \vtop{%
        \hbox{\box1}%
        \hbox{%
          \oplput(\count@ii,0.75){%
            \ophline(0,0){1}}%
          \oplput(\count@ii,0.75){%
            \ophline(1,0){\OP@tosub@w}}%
          \op@makebox{\the\count@iii}{0}%
          {remainderstyle.\the\count@iv}{rest}%
          \oplput(\count@ii,1.5){$-$}%
          \box0}%
      }%
    }%
    \parindent=\op@saveparindent
    \leavevmode\hbox{%
      \box1
      \kern0.5\opcolumnwidth
      \vrule
      \kern0.5\opcolumnwidth
      \box2}%
    \endgroup
  }
  \makeatother