/****************************************************************************************

	RealWide.h

	Copyright: (c) 2001 Eovia Corp. All rights reserved.

	Author:	Ray Dream (orig. JohnS) 
	Date:		3/2/98

	Revision History

	when		who			what & why
	==========	==========	======================================================
	3/4/98		Greg		Initial conversion (real to real)

*****************************************************************************************/

#ifndef __REALWIDE__
#define __REALWIDE__

#if CP_PRAGMA_ONCE
#pragma once
#endif

#if 1

#include "Real.h"

typedef real32				RealWide;

#define	RealWideMul(xx,yy)	((xx)*(yy))

#define kRealWideOne		kRealOne
#define kRealWideMinusOne	kRealMinusOne
#define kRealWideZero		kRealZero
#define kRealWideMax		kRealMax
#define kRealWideMin		kRealMin
#define kRealWideEpsilon	kRealEpsilon
#define kRealWideOneHalf	kRealOneHalf

#define RealWideSqrt		RealSqrt

#else

#include "MCBasicTypes.h"

class  RealWide
{
	public:
	
		enum Sign 
		{
			kNeg	= -1,
			kZero	= 0,
			kPos	= 1
		};

				RealWide 		operator+			(RealWide xx) const;
				RealWide 		operator-			(RealWide xx) const;
				RealWide 		operator-			(void) const;
				RealWide 		operator>>			(unsigned int16 ss) const;
				RealWide 		operator<<			(unsigned int16 ss) const;
				void 			operator+=			(const RealWide& xx);
				void 			operator-=			(const RealWide& xx);
				void 			operator>>=			(unsigned int16 ss); 
				void 			operator<<=			(unsigned int16 ss); 
				boolean 		operator>=			(RealWide xx) const;
				boolean 		operator>			(RealWide xx) const;
				boolean 		operator<			(RealWide xx) const;
				boolean 		operator<=			(RealWide xx) const;
				boolean 		operator==			(RealWide xx) const;
				boolean 		operator!=			(RealWide xx) const;
		friend	real			operator/			(const RealWide &xx,const RealWide &yy);

		friend	RealWide 		RealWideMul			(real xx,real yy);
		friend	int32 			RealWideFloor		(const RealWide &xx);
		friend	int32 			RealWideCeil		(const RealWide &xx);
		friend	real  			RealWideSqrt		(const RealWide& xx);

		friend	RealWide 		RealToRealWide		(const real& xx);
		friend	inline RealWide LongToRealWide		(int32 xx) {RealWide buf; buf.fHi=xx; buf.fLo=0; return buf;}
		real 					ToReal				() const;

				void 			Negate				(void);
				Sign 			GetSign				(void) const;
				void 			Absolute			(void);
				unsigned int32 	SquareRoot			(void) const;

				int32 			GetHi				() const {return fHi;}
				unsigned int32 	GetLo				() const {return fLo;}
				void 			SetHi				(int32 hi) {fHi=hi;}
				void 			SetLo				(unsigned int32 lo) {fLo=lo;}
				void 			SetHiLo				(int32 hi,unsigned int32 lo) {fHi=hi;fLo=lo;}
				int 			GetFirstOnePosition	(void) const;


	protected:

		int32			fHi;
		unsigned int32	fLo;
};

extern const RealWide kRealWideOne;
extern const RealWide kRealWideMinusOne;
extern const RealWide kRealWideZero;
extern const RealWide kRealWideMax;
extern const RealWide kRealWideMin;
extern const RealWide kRealWideEpsilon;
extern const RealWide kRealWideOneHalf;

#endif

#endif