Numeric Functions

// Adjust [n] to the next higher multiple of [p2]. The [p2] n must be a power of 2.
// Example: RVSnap(24) == 32;
RVAPI ulong Snap(ulong n, uint p2);

// Get the shift [n] that is the next higher power of 2 above [n].
// Example: 1 << RVShift(24) == 32.
RVAPI uint Shift(ulong n);

// Get random int between [min] and [max] inclusive.
RVAPI int RndInt(int min, int max);

// Get random float between [min] and [max] inclusive.
RVAPI float RndFlt(float min, float max);

// Clamp int [n] within range inclusive.
RVAPI int ClampInt(int n, int low, int high);

// Clamp float [n] within range inclusive.
RVAPI float ClampFlt(float n, float low, float high);

// Bounce int [n] off end of range inclusive.
RVAPI int BounceInt(int n, int low, int high);

// Bounce float [n] off end of range inclusive.
RVAPI float BounceFlt(float n, float low, float high);

// Wrap int [n] around range inclusive.
RVAPI  int WrapInt(int n, int low, int high);

// Wrap float [n] around range inclusive.
RVAPI float WrapFlt(float n, float low, float high);

// Get int [n]'s normalized range position.
RVAPI float NormInt(int n, int low, int high);

// Get float [n]'s normalized range position.
RVAPI float NormFlt(float n, float low, float high);

// Normalize [angle].
RVAPI float NormAngle(float angle);

// Get angle between angles.
RVAPI float AngleDelta(float angleA, float angleB);

// Convert radian angle [rad] to normalized angle.
RVAPI float RadToNA(float rad);

// Convert normalized angle [angle] to radian angle.
RVAPI float NAToRad(float angle);

// Get minimum of 2 int values.
RVAPI int MinInt(int a, int b);

// Get minimum of 2 float values.
RVAPI float MinFlt(float a, float b);

// Get maximum of 2 int values.
RVAPI int MaxInt(int a, int b);

// Get maximum of 2 float values.
RVAPI float MaxFlt(float a, float b);

// Get absolute [n] of int [n].
RVAPI int AbsInt(int n);

// Get absolute [n] of float [n].
RVAPI float AbsFlt(float n);

// Get sign of int [n].
RVAPI int SignInt(int n);

// Get sign of float [n].
RVAPI int SignFlt(float n);

// Determine if difference between float values are within [epsilon].
RVAPI float EqualFlt(float a, float b, float epsilon = .0001f);

// Determine if difference between double values are within [epsilon].
RVAPI double EqualDbl(double a, double b, double epsilon = .0000001f);

// Swap int values.
RVAPI void SwapInt(int *a, int *b);

// Swap float values.
RVAPI void SwapFlt(float *a, float *b);