# MCMath.h File Reference

## Defines
#define | ceilfix(a) ((a+_fixunder1)&_fixover1)
#define | floorfix(a) ((a)&_fixover1)
#define | ceilfix2int(a) ((a+_fixunder1)>>_shiftamt)
#define | floorfix2int(a) ((a)>>_shiftamt)
#define | MC_Clamp(val, a, b) (MC_Min (MC_Max (val,a), b))
#define | MC_AbsL(a) ((a)<_L0?(-(a)):(a))
#define | MC_AbsF(a) ((a)<_0?(-(a)):(a))
#define | MC_SgnL(a) ((a)<_L0?(-(a)):(a))
#define | MC_SgnF(a) ((a)<_0?(-(a)):(a))
#define | MC_Between(val, b, c) ((val>=b)&&(val<c))
## Functions
int8 | MC_Max (int8 a, int8 b)
uint8 | MC_Max (uint8 a, uint8 b)
int16 | MC_Max (int16 a, int16 b)
uint16 | MC_Max (uint16 a, uint16 b)
int32 | MC_Max (int32 a, int32 b)
uint32 | MC_Max (uint32 a, uint32 b)
uint64 | MC_Max (uint64 a, uint64 b)
int64 | MC_Max (int64 a, int64 b)
real32 | MC_Max (real32 a, real32 b)
real64 | MC_Max (real64 a, real64 b)
int8 | MC_Min (int8 a, int8 b)
uint8 | MC_Min (uint8 a, uint8 b)
int16 | MC_Min (int16 a, int16 b)
uint16 | MC_Min (uint16 a, uint16 b)
int32 | MC_Min (int32 a, int32 b)
uint32 | MC_Min (uint32 a, uint32 b)
uint64 | MC_Min (uint64 a, uint64 b)
int64 | MC_Min (int64 a, int64 b)
real32 | MC_Min (real32 a, real32 b)
real64 | MC_Min (real64 a, real64 b)
int8 | MC_Max (int8 a, int8 b, int8 c)
int8 | MC_Min (int8 a, int8 b, int8 c)
uint8 | MC_Max (uint8 a, uint8 b, uint8 c)
uint8 | MC_Min (uint8 a, uint8 b, uint8 c)
int16 | MC_Max (int16 a, int16 b, int16 c)
int16 | MC_Min (int16 a, int16 b, int16 c)
uint16 | MC_Max (uint16 a, uint16 b, uint16 c)
uint16 | MC_Min (uint16 a, uint16 b, uint16 c)
int32 | MC_Max (int32 a, int32 b, int32 c)
int32 | MC_Min (int32 a, int32 b, int32 c)
uint32 | MC_Max (uint32 a, uint32 b, uint32 c)
uint32 | MC_Min (uint32 a, uint32 b, uint32 c)
real32 | MC_Max (real32 a, real32 b, real32 c)
real32 | MC_Min (real32 a, real32 b, real32 c)
real64 | MC_Max (real64 a, real64 b, real64 c)
real64 | MC_Min (real64 a, real64 b, real64 c)
## Variables
const int32 | _L0 = 0
const int32 | _L1 = 1
const int32 | _L2 = 2
const int32 | _LNeg = -1
const real32 | _0 = (real32)(0.0)
const real32 | _1 = (real32)(1.0)
const int32 | _shiftamt = 16
const int32 | _byteshift = _shiftamt - 8
const int32 | _fixhalf = (_L1<<(_shiftamt-_L1))
const int32 | _int2fix = (_L1<<_shiftamt)
const int32 | _fixunder1 = _int2fix - 1
const int32 | _fixover1 = ~_fixunder1
const real32 | _real2fix = (real32)_int2fix
const real32 | _fix2real = _1/_real2fix

## Define Documentation

#define ceilfix | ( | a |  | ) | ((a+_fixunder1)&_fixover1)

#define ceilfix2int | ( | a |  | ) | ((a+_fixunder1)>>_shiftamt)

#define floorfix | ( | a |  | ) | ((a)&_fixover1)

#define floorfix2int | ( | a |  | ) | ((a)>>_shiftamt)

#define MC_AbsF | ( | a |  | ) | ((a)<_0?(-(a)):(a))

#define MC_AbsL | ( | a |  | ) | ((a)<_L0?(-(a)):(a))

#define MC_Between | ( | val,
|  | b,
|  | c |  | ) | ((val>=b)&&(val<c))

#define MC_Clamp | ( | val,
|  | a,
|  | b |  | ) | (MC_Min (MC_Max (val,a), b))

#define MC_SgnF | ( | a |  | ) | ((a)<_0?(-(a)):(a))

#define MC_SgnL | ( | a |  | ) | ((a)<_L0?(-(a)):(a))

## Function Documentation

real64 MC_Max | ( | real64 | a,
|  | real64 | b,
|  | real64 | c |
| ) |  |  | `[inline]`

real32 MC_Max | ( | real32 | a,
|  | real32 | b,
|  | real32 | c |
| ) |  |  | `[inline]`

uint32 MC_Max | ( | uint32 | a,
|  | uint32 | b,
|  | uint32 | c |
| ) |  |  | `[inline]`

int32 MC_Max | ( | int32 | a,
|  | int32 | b,
|  | int32 | c |
| ) |  |  | `[inline]`

uint16 MC_Max | ( | uint16 | a,
|  | uint16 | b,
|  | uint16 | c |
| ) |  |  | `[inline]`

int16 MC_Max | ( | int16 | a,
|  | int16 | b,
|  | int16 | c |
| ) |  |  | `[inline]`

uint8 MC_Max | ( | uint8 | a,
|  | uint8 | b,
|  | uint8 | c |
| ) |  |  | `[inline]`

int8 MC_Max | ( | int8 | a,
|  | int8 | b,
|  | int8 | c |
| ) |  |  | `[inline]`

real64 MC_Max | ( | real64 | a,
|  | real64 | b |
| ) |  |  | `[inline]`

real32 MC_Max | ( | real32 | a,
|  | real32 | b |
| ) |  |  | `[inline]`

int64 MC_Max | ( | int64 | a,
|  | int64 | b |
| ) |  |  | `[inline]`

uint64 MC_Max | ( | uint64 | a,
|  | uint64 | b |
| ) |  |  | `[inline]`

uint32 MC_Max | ( | uint32 | a,
|  | uint32 | b |
| ) |  |  | `[inline]`

int32 MC_Max | ( | int32 | a,
|  | int32 | b |
| ) |  |  | `[inline]`

uint16 MC_Max | ( | uint16 | a,
|  | uint16 | b |
| ) |  |  | `[inline]`

int16 MC_Max | ( | int16 | a,
|  | int16 | b |
| ) |  |  | `[inline]`

uint8 MC_Max | ( | uint8 | a,
|  | uint8 | b |
| ) |  |  | `[inline]`

int8 MC_Max | ( | int8 | a,
|  | int8 | b |
| ) |  |  | `[inline]`

real64 MC_Min | ( | real64 | a,
|  | real64 | b,
|  | real64 | c |
| ) |  |  | `[inline]`

real32 MC_Min | ( | real32 | a,
|  | real32 | b,
|  | real32 | c |
| ) |  |  | `[inline]`

uint32 MC_Min | ( | uint32 | a,
|  | uint32 | b,
|  | uint32 | c |
| ) |  |  | `[inline]`

int32 MC_Min | ( | int32 | a,
|  | int32 | b,
|  | int32 | c |
| ) |  |  | `[inline]`

uint16 MC_Min | ( | uint16 | a,
|  | uint16 | b,
|  | uint16 | c |
| ) |  |  | `[inline]`

int16 MC_Min | ( | int16 | a,
|  | int16 | b,
|  | int16 | c |
| ) |  |  | `[inline]`

uint8 MC_Min | ( | uint8 | a,
|  | uint8 | b,
|  | uint8 | c |
| ) |  |  | `[inline]`

int8 MC_Min | ( | int8 | a,
|  | int8 | b,
|  | int8 | c |
| ) |  |  | `[inline]`

real64 MC_Min | ( | real64 | a,
|  | real64 | b |
| ) |  |  | `[inline]`

real32 MC_Min | ( | real32 | a,
|  | real32 | b |
| ) |  |  | `[inline]`

int64 MC_Min | ( | int64 | a,
|  | int64 | b |
| ) |  |  | `[inline]`

uint64 MC_Min | ( | uint64 | a,
|  | uint64 | b |
| ) |  |  | `[inline]`

uint32 MC_Min | ( | uint32 | a,
|  | uint32 | b |
| ) |  |  | `[inline]`

int32 MC_Min | ( | int32 | a,
|  | int32 | b |
| ) |  |  | `[inline]`

uint16 MC_Min | ( | uint16 | a,
|  | uint16 | b |
| ) |  |  | `[inline]`

int16 MC_Min | ( | int16 | a,
|  | int16 | b |
| ) |  |  | `[inline]`

uint8 MC_Min | ( | uint8 | a,
|  | uint8 | b |
| ) |  |  | `[inline]`

int8 MC_Min | ( | int8 | a,
|  | int8 | b |
| ) |  |  | `[inline]`

## Variable Documentation

const real32 _0 = (real32)(0.0)

const real32 _1 = (real32)(1.0)

const int32 _byteshift = _shiftamt - 8

const real32 _fix2real = _1/_real2fix

const int32 _fixhalf = (_L1<<(_shiftamt-_L1))

const int32 _fixover1 = ~_fixunder1

const int32 _fixunder1 = _int2fix - 1

const int32 _int2fix = (_L1<<_shiftamt)

const int32 _L0 = 0

const int32 _L1 = 1

const int32 _L2 = 2

const int32 _LNeg = -1

const real32 _real2fix = (real32)_int2fix

const int32 _shiftamt = 16