/* Calculate the square root of an integer. 
This routine calculates the integer square root,  */
fixed_t fixed_sqrt(fixed_t f, int Q)
/* Calculate the square root of an integer. 
This routine calculates the integer square root,  */
fixed_t fixed_sqrt(fixed_t f, int Q)
{
	uint64_t n = (uint64_t) f << Q;
	uint64_t m = 0;
	if (n) {
		int32_t  bshft = (63 - clzll (n)) >> 1;
		uint64_t b = 1LL << bshft;
		do  {
			const uint64_t temp = (m + m + b) << bshft;
			if (n >= temp) {
				m += b;
				n -= temp;
			}
			b >>= 1;
		} while (bshft--);
	}
	return (fixed_t) m;
}