-
Notifications
You must be signed in to change notification settings - Fork 0
/
BigInt_CDLL.cpp
26 lines (24 loc) · 1.33 KB
/
BigInt_CDLL.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include "BigInt.h"
#include <string>
#define DLLCALL _declspec(dllexport)
extern "C"
{
DLLCALL BigInt* BigInt_CreateFromString(const char* str) {return new BigInt(str);}
DLLCALL BigInt* BigInt_CreateFromInt(long long ll) {return new BigInt(ll);}
DLLCALL void BigInt_Delete(BigInt* bi) {delete bi;}
DLLCALL BigInt* BigInt_Add(const BigInt* lhs, const BigInt* rhs) {return new BigInt(*lhs + *rhs);}
DLLCALL BigInt* BigInt_Multiply(const BigInt* lhs, const BigInt* rhs) {return new BigInt(*lhs * *rhs);}
DLLCALL BigInt* BigInt_Power(const BigInt* lhs, const BigInt* rhs) {return new BigInt(pow(*lhs, rhs->ToUInt()));}
DLLCALL BigInt* BigInt_Subtract(const BigInt* lhs, const BigInt* rhs) {return new BigInt(*lhs - *rhs);}
DLLCALL BigInt* BigInt_Divide(const BigInt* lhs, const BigInt* rhs, BigInt* mod) {return new BigInt(lhs->divide(*rhs, mod));}
DLLCALL BigInt* BigInt_ChangeSign(const BigInt* val) {return new BigInt(-*val);}
DLLCALL BigInt* BigInt_Sqrt(const BigInt* val) {return new BigInt(sqrt(*val));}
DLLCALL int BigInt_Compare(const BigInt* lhs, const BigInt* rhs) {return lhs->Compare(*rhs);}
DLLCALL std::string* BigInt_ToString(const BigInt* lhs, const char** pStr)
{
std::string* result=new std::string(lhs->ToString());
*pStr=result->c_str();
return result;
}
DLLCALL void BigInt_FreeString(std::string* str) {delete str;}
}