#ifndef __GE_MATH_H
#define __GE_MATH_H

#include "ge_sys_math.h"	

#ifndef GCC34T
	#define GCC34T
#endif

typedef UCHAR PIX;
typedef UCHAR PIX_C;
typedef UWORD PIX_W;
typedef SReal PIX_F;

Bool CompareFloatTolerant(SReal a, SReal b);
Bool CompareFloatTolerant(LReal a, LReal b);

// TRUE for FP_NORMAL, FP_SUBNORMAL, FP_ZERO
// FALSE for FP_NAN, FP_INFINITE
inline Bool CheckFloat(SReal r)
{
	union{ SReal f; ULONG u;}u = {r};

	return (( u.u >> 23 ) & 0xff ) != 0xff;
}

inline Bool CheckFloat(LReal r)
{
	union{ LReal f; LULONG u;}u = {r};

	return (( ~u.u >> 52 ) & 0x7ff ) != 0;
}

// Only NANs and Infinity are corrected - denormalized numbers not
inline SReal RepairFloat( SReal r )
{
	if ( !CheckFloat(r) )
		return 0.0;

	return r;
}

inline LReal RepairFloat( LReal r )
{
	if ( !CheckFloat(r) )
		return 0.0;

	return r;
}

extern Bool __NET;
extern Bool __SERVER;
extern Bool __CLIENT;
extern Bool __BODYPAINT;
extern Bool __STUDENT;
extern Bool __PARALLEL;
extern Bool __UPDATER;
extern Bool __INSTALLER;
extern Bool __LICENSESERVER;
extern Bool __MEDIZINI;

#define C4D_FOUR_BYTE(x1,x2,x3,x4)	( (x1<<24) | (x2<<16) | (x3<<8) | x4 )
#define	C4D_RESERVE_PRIVATE_TYPE(type,x)		type x

struct LVector;
struct LMatrix;
struct SVector;
struct SMatrix;

enum _DONTCONSTRUCT
{
	DC
};

// necessary to import in exactly this order
#include "ge_vector.h"
#include "ge_lvector.h"
#include "ge_matrix.h"
#include "ge_lmatrix.h"

#ifdef __SINGLEPRECISION
	typedef SVector Vector;
	typedef SMatrix Matrix;
#else
	typedef LVector Vector;
	typedef LMatrix Matrix;
#endif

#endif
