Skip to content

Commit

Permalink
add isqrt.c
Browse files Browse the repository at this point in the history
  • Loading branch information
palmskog committed Jan 16, 2024
1 parent 9d0e59d commit 9f30af9
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions examples/riscv/isqrt/isqrt.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include <stdint.h>

uint64_t isqrt(uint64_t x) {
uint64_t y = 0;
while ((y+1)*(y+1) <= x) {
y += 1;
}
return y;
}

0 comments on commit 9f30af9

Please sign in to comment.