1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2025-08-08 13:25:12 +00:00
Files
kickc/src/main/kc/include/sqr.h
2021-06-19 22:11:26 +02:00

16 lines
593 B
C

/// @file
/// Table-based implementation of integer square sqr() and square root sqrt()
/// Initialize squares table
/// Uses iterative formula (x+1)^2 = x^2 + 2*x + 1
void init_squares();
/// Find the square of a char value
/// Uses a table of squares that must be initialized by calling init_squares()
unsigned int sqr(char val);
/// Find the (integer) square root of a unsigned int value
/// If the square is not an integer then it returns the largest integer N where N*N <= val
/// Uses a table of squares that must be initialized by calling init_squares()
char sqrt(unsigned int val);