⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hugecalc.h

📁 HugeCalc V5.1.0.1 ----> 这是一套绿色软件
💻 H
字号:

//***********************************************************************
// FileDescription: 	Fast Calculational Algorithm of Huge Integer.
// FileVersion:     	2005-10-18
// ProductVersion:  	5, 1, 0, 1
//
// Portability:     	Standard C++
// Base Classes:    	None.
// Related Document:	HugeCalc.chm
//
// Copyright 1992-2005 by Guo XianQiang. All rights reserved.
//
//
// Web: http://maths.myrice.com/
// BBS: http://rd.xilubbs.com/
// E-Mail: gxqcn@163.com; HugeCalc@Gmail.com
//***********************************************************************

// If you find any bug or you want to add some useful function
// please email to me. Redistribution and use in source are
// permitted provided that: source distributions retain this
// entire copyright notice and comment.
// 如果你在使用中发现BUG或添加了功能,请Email我。
// 你可以使用与发布该文件,但不得进行商业用途。
// 你的发布要包含完整的本文件头。

/*
附加说明:

	1、HugeCalc 用到了 SGI-STL,所以请到 http://www.sgi.com/tech/stl/download.html 下载安装一份STL,
	   并在 VC 的 Tools->Options->Directories->Include files 中将 SGI-STL 目录加进去并提到最前;
	   但如果您根本不会去调用带有 < vector > 接口的函数,则该过程完全可省略。

	2、调用程序所在目录必须为 ../CopyrightByGuoXianqiang[/..]/,否则 HugeCalc.dll 会拒绝任何服务。

	3、如需解除上述限制,请在 HugeCalc.chm 中进行“注册”。

	4、最新版的 HugeCalc 下载地址:http://maths.myrice.com/download/HugeCalc.rar

	5、欢迎进行各项测试,如果发现bug,请及时联系,谢谢!

	6、请务必遵守配套的 HugeCalc.chm 的相关声明!

郭先强(gxqcn@163.com; HugeCalc@Gmail.com)
2005-10-18
*/

#ifndef __cplusplus
	#error Must use C++ for HugeCalc.
#endif

#if !defined(AFX_HUGECALC_H__AB0E3F9A_260E_43B6_BDFE_FCD5C19BBC24__INCLUDED_)
#define AFX_HUGECALC_H__AB0E3F9A_260E_43B6_BDFE_FCD5C19BBC24__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include < WINDOWS.H >

// must use SGI-STL, URL: http://www.sgi.com/tech/stl/download.html
#include < vector >	//stl_vector.h
using namespace std;

//add to your .cpp file:
//#ifndef _UNICODE
//	#pragma comment( lib, "../HugeCalc_Dll_Import/Lib/HugeCalc.lib" )
//#else
//	#pragma comment( lib, "../HugeCalc_Dll_Import/Lib/HugeCalcU.lib" )
//#endif


// ================ typedef ================

#ifndef _SINT32
	#define _SINT32
	typedef INT32 SINT32;
#endif // !defined(_SINT32)

#ifndef _SINT64
	#define _SINT64
	typedef INT64 SINT64;
#endif // !defined(_SINT64)

#ifndef _U32_VECTOR
	#define _U32_VECTOR
	#ifndef __SGI_STL_VECTOR
		typedef vector< UINT32 > U32_VECTOR;
	#else
		typedef vector< UINT32, malloc_alloc > U32_VECTOR;
	#endif
#endif // !defined(_U32_VECTOR)

// ================ enum ================

#ifndef _HCLicenseLevel
	#define _HCLicenseLevel
	typedef enum tagHCLicenseLevel
	{
		HC_LICENSE_NONE		= -1,
		HC_LICENSE_LIMITED	=  0,
		HC_LICENSE_ALL		=  1,
	}HCLicenseLevel;
#endif // !defined(_HCLicenseLevel)

#ifndef _HCSIGN
	#define _HCSIGN
	typedef enum tagSIGN
	{
		SIGN_NEG	= -1,	// Negative
		SIGN_ZERO	=  0,	// Zero
		SIGN_POS	=  1,	// Positive
	}SIGN;
#endif // !defined(_HCSIGN)

#ifndef _HCTimerUnit
	#define _HCTimerUnit
	typedef enum tagTimerUnit
	{
		TIMER_UNIT_ms	= 0,	// millisecond
		TIMER_UNIT_us	= 1,	// microsecond
		TIMER_UNIT_ns	= 2,	// millimicrosecond
	}TimerUnit;
#endif // !defined(_HCTimerUnit)

#ifndef _HCErrCode
	#define _HCErrCode
	typedef enum tagHCErrCode
	{
		HCERR_NONE			=  0,
		HCERR_NO_LICENSE	= -1,
		HCERR_USER_STOP		= -2,
		HCERR_OUTOF_MEM		= -3,
		HCERR_DIV_ZERO		= -4,
		HCERR_BASE2SMALL	= -5,
		HCERR_CARRY2SMALL	= -6,
		//...
	}HCErrCode;
#endif // !defined(_HCErrCode)

// ================ CONST ================

#ifndef _FORMAT_SHOW
	#define _FORMAT_SHOW

	CONST BYTE FS_NORMAL		= 0x00;	// normal format
	CONST BYTE FS_BAND			= 0x01;	// ' ' or ',' at pre 3[or4] digits from right
	CONST BYTE FS_BAND_SPACE	= 0x02;	// must setting "| FS_BAND"
	CONST BYTE FS_SIGN			= 0x04;	// even if "+"
	CONST BYTE FS_SIGN_SPACE	= 0x08;	// between sign and number
	CONST BYTE FS_CHAR_LOWER	= 0x10;	// will use [0-9a-z]; otherwise, use [0-9A-Z]
	CONST BYTE FS_DEFAULT		= FS_BAND | FS_BAND_SPACE | FS_SIGN_SPACE;	// default format
#endif // !defined(_FORMAT_SHOW)


#define HUGECALC_API __declspec(dllimport)
#define COMMON_API HUGECALC_API

namespace HugeCalc
{
//	class CHugeInt;
//	class CHugeIntX;

	COMMON_API CONST LPCTSTR GetSN( VOID );
	COMMON_API CONST HCLicenseLevel GetLicenseLevel( VOID );

	COMMON_API CONST LPCTSTR GetVersion( VOID );
	COMMON_API CONST UINT32 GetExportFunNums( VOID );

	COMMON_API CONST HCErrCode GetLastError( VOID );

	// It usefull when use multithread.
	COMMON_API VOID SetTerminate( CONST BOOL bTerminate = TRUE );
	COMMON_API CONST BOOL IsTerminated( VOID );

	// before calculate, pls call bEnableTimer as TRUE, and after finishing call as FALSE
	COMMON_API VOID ResetTimer( CONST UINT32 u32Timer = 0, CONST TimerUnit enumTimerUnit = TIMER_UNIT_us );
	COMMON_API CONST UINT32 GetTimer( CONST BOOL bEnableTimer = FALSE, CONST TimerUnit enumTimerUnit = TIMER_UNIT_us );
	COMMON_API CONST LPCTSTR ShowTimer( CONST BOOL bEnableTimer = FALSE, CONST BOOL bShowHMS = TRUE );
	COMMON_API VOID EnableTimer( CONST BOOL bEnableTimer = TRUE );

	// InvertMod: x = InvertMod( b, m ) && !(!x) <==> ( b * x ) mod m = 1
	COMMON_API CONST UINT32 InvertMod( CONST UINT32 u32InvertBase, CONST UINT32 u32Mod );

	// PowMod
	COMMON_API CONST UINT32 PowMod( CONST UINT32 u32Base, CONST UINT32 u32Exp, CONST UINT32 u32Mod );
	COMMON_API CONST UINT32 PowMod( CONST UINT32 u32Base, CONST SINT32 s32Exp, CONST UINT32 u32Mod );

	// Greatest Common Divisor
	COMMON_API CONST UINT32 Gcd( CONST UINT32 u32Num1, CONST UINT32 u32Num2 );
	COMMON_API CONST UINT32 Gcd( CONST SINT32 s32Num, CONST UINT32 u32Num );
	COMMON_API CONST UINT32 Gcd( CONST UINT32 u32Num, CONST SINT32 s32Num );
	COMMON_API CONST UINT32 Gcd( CONST SINT32 s32Num1, CONST SINT32 s32Num2 );

	COMMON_API CONST UINT32 Gcd( CONST U32_VECTOR& vU32Num );

	// GcdEx: g = GcdEx( x, y, u, v ) = u * x + v * y. g is always positive, even if one or both of u and v are negative.
	COMMON_API CONST UINT32 GcdEx( SINT32 &x, SINT32 &y, CONST SINT32 u, CONST SINT32 v );

	// Lowest Common Multiple
	COMMON_API CONST UINT64 Lcm( CONST UINT32 u32Num1, CONST UINT32 u32Num2 );
	COMMON_API CONST UINT64 Lcm( CONST SINT32 s32Num, CONST UINT32 u32Num );
	COMMON_API CONST UINT64 Lcm( CONST UINT32 u32Num, CONST SINT32 s32Num );
	COMMON_API CONST UINT64 Lcm( CONST SINT32 s32Num1, CONST SINT32 s32Num2 );
}

using namespace HugeCalc;

#endif // !defined(AFX_HUGECALC_H__AB0E3F9A_260E_43B6_BDFE_FCD5C19BBC24__INCLUDED_)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -