General math functions
Return the maximum integer between int a
and int b
int max_int(int a, int b);
Return the minimum integer between int a
and int b
int min_int(int a, int b);
Clamps an integer between a high and low value
int clamp_int(int i, int low, int high);
Converts a string representing a binary number into an integer. Supports underscores as spacing
int binstr_to_int(const char *s); /* Usage */ int a = binstr_to_int("10011101"); int b = binstr_to_int("1001_1101_0010_1011");
Uses bresenham’s line algorithim to generate a line in 2D space. Returns a pointer to an array of Point
. The sz
parameter holds the size of the array.
Point *bresenham(int x0, int y0, int x1, int y1, size_t *sz);
Works the same as bresenham()
but uses the Point
struct instead of int
Point *bresenham_p(Point p1, Point p2, size_t *sz);
Returns 1
if i
is a power of two, otherwise returns 1
.
int is_power_of_two(int i);