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

📄 hugecalc.h

📁 HugeCalc 是一款高精度算法库
💻 H
字号:

//***********************************************************************
// FileDescription: 	Fast Calculational Algorithm of Huge Integer.
// FileVersion:     	2005-05-01
// ProductVersion:  	5, 0, 0, 0
//
// 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.h、HugeInt.h、HugeIntX.h、HugeCalc.lib、HugeCalcU.lib;用它们可完全调用 HugeCalc.dll、HugeCalcU.dll。

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

	3、调用程序的 name 必须为 ../CopyrightByGuoXianqiang/[../]HugeCalc.exe,否则 HugeCalc.dll 会拒绝任何服务。

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

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

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

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

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

#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;

//#ifndef _UNICODE
//	#pragma comment( lib, "../HugeCalc_Dll_Import/HugeCalc.lib" )
//#else
//	#pragma comment( lib, "../HugeCalc_Dll_Import/HugeCalcU.lib" )
//#endif


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

#ifndef _SINT8
	#define _SINT8
	typedef __int8 SINT8;
#endif // !defined(_SINT8)

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

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

#ifndef _HC_ALLOC
	#define _HC_ALLOC
	typedef __default_alloc_template< TRUE, 0 > HC_ALLOC;
#endif // !defined(_HC_ALLOC)

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

// ================ struct ================

#ifndef _CARRY_PARAM
	#define _CARRY_PARAM
	typedef struct tagCarryParam
	{
		UINT32 u32Carry;
		SINT8 nSign;
		U32_VECTOR vU32Num;
	}CARRY_PARAM;
#endif // !defined(_CARRY_PARAM)

// ================ 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 _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
	// unit: millisecond
	COMMON_API VOID ResetTimer( CONST UINT32 u32Timer = 0 );
	COMMON_API CONST UINT32 GetTimer( CONST BOOL bEnableTimer = FALSE );
	COMMON_API CONST LPCTSTR ShowTimer( CONST BOOL bEnableTimer = FALSE );
	COMMON_API VOID EnableTimer( CONST BOOL bEnableTimer = TRUE );

	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 );

	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 );

	COMMON_API CONST UINT32 PowMod( CONST UINT32 u32Base, CONST UINT32 r, CONST UINT32 u32Mod );
	COMMON_API CONST UINT32 PowMod( CONST UINT32 u32Base, CONST UINT32 r, CONST SINT32 s32Mod );
	COMMON_API CONST SINT64 PowMod( CONST SINT32 s32Base, CONST UINT32 r, CONST UINT32 u32Mod );
	COMMON_API CONST SINT32 PowMod( CONST SINT32 s32Base, CONST UINT32 r, CONST SINT32 s32Mod );
}

using namespace HugeCalc;

#endif // !defined(AFX_HUGECALC_H__AB0E3F9A_260E_43B6_BDFE_FCD5C19BBC24__INCLUDED_)

⌨️ 快捷键说明

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