Macaw OS C reference

Function sgn

#include <macaw.h>
int sgn(double n);

Tells you whether a number is below 0, for things like which way something faces.

Parameters

ndouble
The number to look at.

Returns int

-1 if n is below 0, or 1 otherwise. So sgn(0) is 1, not 0.

In Handy maths for games, with rnd, mid, clamp, lerp, flr.