#include <stdio.h>
#include <math.h>
typedef unsigned char uint8;
typedef unsigned short int uint16;
typedef unsigned long int uint32;
uint32 isqrt32(uint32 n) {
register uint32 root, remainder, place;
root = 0;
remainder = n;
place = 0x40000000;
while (place > remainder)
place >>= 2;
while (place) {
if (remainder >= root + place) {
remainder -= root + place;
root += (place << 1);
}
root >>= 1;
place >>= 2;
}
return root;
}
main() {
uint32 sq, error;
for(uint32 n=0; n<100000000; n=n+1+(n>>12)) {
sq = isqrt32(n);
printf("isqrt(%lu)= %lu error=%lu\n", n
, sq
, error
); }
}