Skip to content

Instantly share code, notes, and snippets.

View foobaz's full-sized avatar

William MacKay foobaz

  • Alyrica Networks
  • Cascadia
View GitHub Profile
@foobaz
foobaz / sqrt.c
Last active October 11, 2022 13:06
Integer square root algorithm
/*
Just like integer division, these functions round down to an integer.
Running this program should produce the following output:
sqrt(3735928559) == 61122
61122^2 == 3735898884
sqrt(244837814094590) == 15647294
15647294^2 == 244837809522436
This algorithm comes from Jack W. Crenshaw's 1998 article in Embedded: