This document is a part of a collection of macros. For introductory remarks, see the first part (General Purpose Macros).
For a review of macro-syntax rules and related tips and tricks, see Writing Macros.
For the typedefs DWORD, WORD, BYTE and CHAR, click here.
Maximum and Minimum Values
Code:
#define mMax(a,b) (mIsGT(b,a)?(b):(a))
#define mMax2(a,b) mMax(a,b)
#define mMax3(a,b,c) mMax(a,mMax(b,c))
#define mMax4(a,b,c,d) mMax(mMax(a,b),mMax(c,d))
#define mMax5(a,b,c,d,e) mMax(mMax(a,b),mMax3(c,d,e))
#define mMax6(a,b,c,d,e,f) mMax(mMax3(a,b,c),mMax3(d,e,f))
#define mMin(a,b) (mIsLT(b,a)?(b):(a))
#define mMin2(a,b) mMin(a,b)
#define mMin3(a,b,c) mMin(a,mMin(b,c))
#define mMin4(a,b,c,d) mMin(mMin(a,b),mMin(c,d))
#define mMin5(a,b,c,d,e) mMin(mMin(a,b),mMin3(c,d,e))
#define mMin6(a,b,c,d,e,f) mMin(mMin3(a,b,c),mMin3(d,e,f))
Arguments:
a through f stand for any entities (including expressions) which are compatible with the relational operators > (for maximum searches) or < (for minimum searches).
These macros rely on the macros mIsGT and mIsLT.
Maximum and Minimum Absolute Values
Code:
#define mMaxAbs(a,b) mMax(mAbs(a),mAbs(b))
#define mMaxAbs2(a,b) mMaxAbs(a,b)
#define mMaxAbs3(a,b,c) mMax3(mAbs(a),mAbs(b),mAbs(c))
#define mMaxAbs4(a,b,c,d) mMax4(mAbs(a),mAbs(b),mAbs(c),mAbs(d))
#define mMaxAbs5(a,b,c,d,e) mMax5(mAbs(a),mAbs(b),mAbs(c),mAbs(d),mAbs(e))
#define mMaxAbs6(a,b,c,d,e,f) mMax6(mAbs(a),mAbs(b),mAbs(c),mAbs(d),mAbs(e),mAbs(f))
#define mMinAbs(a,b) mMin(mAbs(a),mAbs(b))
#define mMinAbs2(a,b) mMinAbs(a,b)
#define mMinAbs3(a,b,c) mMin3(mAbs(a),mAbs(b),mAbs(c))
#define mMinAbs4(a,b,c,d) mMin4(mAbs(a),mAbs(b),mAbs(c),mAbs(d))
#define mMinAbs5(a,b,c,d,e) mMin5(mAbs(a),mAbs(b),mAbs(c),mAbs(d),mAbs(e))
#define mMinAbs6(a,b,c,d,e,f) mMin6(mAbs(a),mAbs(b),mAbs(c),mAbs(d),mAbs(e),mAbs(f))
Arguments:
a through f stand for any entities (including expressions) which are compatible with the relational operators > (for maximum searches) or < (for minimum searches).
These macros rely on the relational macros mIsGT, mIsLT and mAbs.
Extreme Values (signed)
Code:
#define mExtreme(a,b) (mIsGT(mAbs(b),mAbs(a))?(b):(a))
#define mExtreme2(a,b) mExtreme(a,b)
#define mExtreme3(a,b,c) mExtreme(a,mExtreme(b,c))
#define mExtreme4(a,b,c,d) mExtreme(mExtreme(a,b),mExtreme(c,d))
#define mExtreme5(a,b,c,d,e) mExtreme(mExtreme(a,b),mExtreme3(c,d,e))
#define mExtreme6(a,b,c,d,e,f) mExtreme(mExtreme3(a,b,c),mExtreme3(d,e,f))
Arguments:
a through f stand for any entities (including expressions) which are compatible with the relational operator >.
These macros rely on the relational macro mIsGT.
Ranges
Code:
#define mRange(a,b) (mMax(a,b)-nMin(a,b))
#define mRange2(a,b) mRange(a,b)
#define mRange3(a,b,c) (mMax(a,b,c)-nMin(a,b,c))
#define mRange4(a,b,c,d) (mMax(a,b,c,d)-nMin(a,b,c,d))
#define mRange5(a,b,c,d,e) (mMax(a,b,c,d,e)-nMin(a,b,c,d,e))
#define mRange6(a,b,c,d,e,f) (mMax(a,b,c,d,e,f)-nMin(a,b,c,d,e,f))
Arguments:
a through f stand for any entities (including expressions) which are compatible with the relational operator >.
These macros rely on the relational macro mIsGT.