HF RL Explorer

You have inherited a C codebase that implements a small numerical library for fixed-point arithmetic. The…

You have inherited a C codebase that implements a small numerical library for fixed-point arithmetic. The…: a task in repo2rlenv-tmax (Harbor dataset). / Integer square root: returns floor(sqrt(n)) / uint32 t isqrt32(uint32 t n) { if (n == 0) return 0; uint32 t x = n; uint32 t y = (x + 1) / 2; /…

The task

/* Integer square root: returns floor(sqrt(n)) */ uint32_t isqrt32(uint32_t n) { if (n == 0) return 0; uint32_t x = n; uint32_t y = (x + 1) / 2; /* BUG A */ while (y < x) { x = y; y = (x + n / x) / 2; } return x; }

Part of FineEnvs/repo2rlenv-tmax.