Would it be more useful to have a true integer square root rather than overloading the real square root? Something like:

T intsqrt(T)(T i) {
   T bitMask = 1;
   T result = 0;

   bitMask <<= T.sizeof * 4 - 1;

   while (bitMask) {
       result |= bitMask;
       if ((result * result) > i) {
           result &= ~bitMask;
       }
       bitMask >>= 1;
   }

   return result;
}


-=mike=-

Reply via email to