/*	Copyright  (c)	Günter Woigk 2011 - 2015
					mailto:kio@little-bat.de

	This file is free software

 	This program is distributed in the hope that it will be useful,
 	but WITHOUT ANY WARRANTY; without even the implied warranty of
 	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

	Redistribution and use in source and binary forms, with or without 
	modification, are permitted provided that the following conditions are met:

	• Redistributions of source code must retain the above copyright notice, 
	  this list of conditions and the following disclaimer.
	• Redistributions in binary form must reproduce the above copyright notice, 
	  this list of conditions and the following disclaimer in the documentation 
	  and/or other materials provided with the distribution.

	THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
	AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 
	THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 
	PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 
	CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
	EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 
	PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 
	OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
	WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 
	OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
	ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/


//	vcc header for the
//
//	gnu multi-precision library


#include "stdc.h"



type mp_int =
{
  	int 	_mp_alloc;	// Number of *limbs* allocated and pointed to by the _mp_d field.  
  	int 	_mp_size;	// abs(_mp_size) is the number of limbs the last field points to.  
  						// If _mp_size is negative this is a negative number.  
  	void*	_mp_d;		// Pointer to the limbs.  	
}


scope mp_int
{
	bool 	operator > 	( mp_int¢, mp_int¢ ) 	= opcode operator >
	bool 	operator >= ( mp_int¢, mp_int¢ ) 	= opcode operator >=
	bool 	operator < 	( mp_int¢, mp_int¢ ) 	= opcode operator <
	bool 	operator <= ( mp_int¢, mp_int¢ ) 	= opcode operator <=
	bool 	operator ==	( mp_int¢, mp_int¢ ) 	= opcode operator ==
	bool 	operator != ( mp_int¢, mp_int¢ ) 	= opcode operator !=

	bool 	operator > 	( mp_int¢, uint64 ) 	= opcode operator >
	bool 	operator >= ( mp_int¢, uint64 ) 	= opcode operator >=
	bool 	operator < 	( mp_int¢, uint64 ) 	= opcode operator <
	bool 	operator <= ( mp_int¢, uint64 ) 	= opcode operator <=
	bool 	operator ==	( mp_int¢, uint64 ) 	= opcode operator ==
	bool 	operator != ( mp_int¢, uint64 ) 	= opcode operator !=

	bool 	operator > 	( mp_int¢, int64 ) 		= opcode operator >
	bool 	operator >= ( mp_int¢, int64 ) 		= opcode operator >=
	bool 	operator < 	( mp_int¢, int64 ) 		= opcode operator <
	bool 	operator <= ( mp_int¢, int64 ) 		= opcode operator <=
	bool 	operator ==	( mp_int¢, int64 ) 		= opcode operator ==
	bool 	operator != ( mp_int¢, int64 )	 	= opcode operator !=

	bool 	operator > 	( mp_int¢, float64 ) 	= opcode operator >
	bool 	operator >= ( mp_int¢, float64 ) 	= opcode operator >=
	bool 	operator < 	( mp_int¢, float64 ) 	= opcode operator <
	bool 	operator <= ( mp_int¢, float64 ) 	= opcode operator <=
	bool 	operator ==	( mp_int¢, float64 ) 	= opcode operator ==
	bool 	operator != ( mp_int¢, float64 ) 	= opcode operator !=

	mp_int	operator +	( mp_int¢, mp_int¢ )	= opcode operator +
	mp_int	operator -	( mp_int¢, mp_int¢ )	= opcode operator -	
	mp_int	operator *	( mp_int¢, mp_int¢ )	= opcode operator *
	mp_int	operator /	( mp_int¢, mp_int¢ )	= opcode operator /
	mp_int	operator %	( mp_int¢, mp_int¢ )	= opcode operator %
	mp_int	operator &	( mp_int¢, mp_int¢ )	= opcode operator &
	mp_int	operator |	( mp_int¢, mp_int¢ )	= opcode operator |
	mp_int	operator ^	( mp_int¢, mp_int¢ )	= opcode operator ^

	mp_int	operator +	( mp_int¢, uint64 )		= opcode operator +
	mp_int	operator -	( mp_int¢, uint64 )		= opcode operator -	
	mp_int	operator *	( mp_int¢, uint64 )		= opcode operator *
	mp_int	operator /	( mp_int¢, uint64 )		= opcode operator /
	mp_int	operator %	( mp_int¢, uint64 )		= opcode operator %

	mp_int	operator +	( mp_int¢, int64 )		= opcode operator +
	mp_int	operator -	( mp_int¢, int64 )		= opcode operator -	
	mp_int	operator *	( mp_int¢, int64 )		= opcode operator *
	mp_int	operator /	( mp_int¢, int64 )		= opcode operator /
	mp_int	operator %	( mp_int¢, int64 )		= opcode operator %

	void	operator +=	( mp_int&, mp_int¢ )	= opcode operator +=	, reverted
	void	operator -=	( mp_int&, mp_int¢ )	= opcode operator -=	, reverted
	void	operator *=	( mp_int&, mp_int¢ )	= opcode operator *=	, reverted
	void	operator /=	( mp_int&, mp_int¢ )	= opcode operator /=	, reverted
	void	operator %=	( mp_int&, mp_int¢ )	= opcode operator %=	, reverted
	void	operator &=	( mp_int&, mp_int¢ )	= opcode operator &=	, reverted
	void	operator |=	( mp_int&, mp_int¢ )	= opcode operator |=	, reverted
	void	operator ^=	( mp_int&, mp_int¢ )	= opcode operator ^=	, reverted

	void	operator +=	( mp_int&, uint64 )		= opcode operator +=	, reverted
	void	operator -=	( mp_int&, uint64 )		= opcode operator -=	, reverted
	void	operator *=	( mp_int&, uint64 )		= opcode operator *=	, reverted
	void	operator /=	( mp_int&, uint64 )		= opcode operator /=	, reverted
	void	operator %=	( mp_int&, uint64 )		= opcode operator %=	, reverted

	void	operator +=	( mp_int&, int64 )		= opcode operator +=	, reverted
	void	operator -=	( mp_int&, int64 )		= opcode operator -=	, reverted
	void	operator *=	( mp_int&, int64 )		= opcode operator *=	, reverted
	void	operator /=	( mp_int&, int64 )		= opcode operator /=	, reverted
	void	operator %=	( mp_int&, int64 )		= opcode operator %=	, reverted
	
	mp_int 	operator <<	( mp_int¢, int32 )		= opcode operator <<
	mp_int 	operator >>	( mp_int¢, int32 )		= opcode operator >>

	void	operator<<=	( mp_int&, int32 )		= opcode operator <<=	, reverted
	void	operator>>=	( mp_int&, int32 )		= opcode operator >>=	, reverted

	mp_int	operator -	( mp_int¢ )				= opcode neg
	mp_int	operator ~	( mp_int¢ )				= opcode cpl

// special

	mp_int	operator /%	( mp_int¢ a, mp_int¢ b )= opcode operator /%	// return a/b; set a = a%b

// dtor:

	mp_int	kill		( mp_int )				= opcode kill
}

	int		sign		( mp_int¢ )				= opcode sign
	mp_int	abs			( mp_int¢ )				= opcode abs

// convert:

	mp_int	new			()						= opcode new
	mp_int	new			( uint32 )				= opcode cast
	mp_int	new			( int32 )				= opcode cast
	mp_int	new			( uint64 )				= opcode cast
	mp_int	new			( int64 )				= opcode cast
	mp_int	new			( float64 )				= opcode cast

	uint8	new			( mp_int¢ )				= opcode cast
	int8	new			( mp_int¢ )				= opcode cast
	uint16	new			( mp_int¢ )				= opcode cast
	int16	new			( mp_int¢ )				= opcode cast
	uint32	new			( mp_int¢ )				= opcode cast
	int32	new			( mp_int¢ )				= opcode cast
	uint64	new			( mp_int¢ )				= opcode cast
	int64	new			( mp_int¢ )				= opcode cast
	float64	new			( mp_int¢ )				= opcode cast
//	float32	new			( mp_int¢ )				= opcode cast
//	float128 new   		( mp_int¢ )				= opcode cast

// other:

	str		numstr		(mp_int¢)				= opcode numstr;
	mp_int	numval		(str¢)					= opcode numval;







