Mobile API Reference  MicroStrategy 2019
BigInt.h
Go to the documentation of this file.
1 //==============================================================================================
2 // FILENAME : BigInt.h
3 // AUTHOR : Xun Feng
4 // CREATION : 2/11/04
5 // Copyright (C) MicroStrategy, Inc. 2001
6 //==============================================================================================
7 #ifndef MDataType_BigInt_h
8 #define MDataType_BigInt_h
9 
11 #include "Base/Base/Buffer.h"
12 
13 namespace MDataType
14 {
15 #define BigIntPlus 0
16 #define BigIntMinus 1
17 #define BigIntTime 2
18 #define BigIntDivide 3
19 
20  //==============================================================================================
21  // BigInt represents an arbitrary length integer
22  //==============================================================================================
23 
24  class BigInt
25  {
26 
27  friend class BigDecimal;
28 
29  private :
30  // members
31  Int32 mSignum;
32  Int32 mDigits;
33  Int32 mLeading0;
34  char * mag;
35  MBase::Buffer *mBuffer;
36 
37  private:
38  // every method is private, only used by BigDecimal
39  BigInt();
40  ~BigInt();
41  BigInt(const BigInt& iBigInt, MBase::Buffer *iBuffer = 0);
42 
43  Int32 Signum() const;
44  Int32 Precision() const;
45 
46  void GetRawForm(const char*& oArray, Int32 &oSignum, Int32& oDigits, Int32& oLeading0);
47 
48  // the input string may contain '.', ignore
49  BigInt(const char *iArray, Int32 iDigits, Int32 iSignum, Int32 iExtra0, bool iKeepLeading0 = true, MBase::Buffer *iBuffer = 0);
50 
51  Int32 CompareABS(const BigInt& val, Int32 iScaleDiff) const;
52  static BigInt* Calculate(Int32 iCal, const BigInt* left, const BigInt* right, Int32 iScaleDiff, MBase::Buffer *iBuffer, Int32 leftscale = 0, Int32 rightscale = 0, Int32 requestscale = 0);
53  static BigInt* CalculateBuf(Int32 iCal, const BigInt* left, const BigInt* right, Int32 iScaleDiff, MBase::Buffer *iBuffer, Int32 iSignum, Int32 leftscale = 0, Int32 rightscale = 0, Int32 requestscale = 0);
54 
55  static void Plus(char *oArray, Int32& oDigits, const BigInt* left, const BigInt* right, Int32 iScaleDiff);
56  static void Minus(char *oArray, Int32& oDigits, const BigInt* left, const BigInt* right, Int32 iScaleDiff);
57  static void Times(char *oArray, Int32& oDigits, const BigInt* left, const BigInt* right);
58  static void Divide(char *oArray, Int32& oDigits, const BigInt* left, const BigInt* right, Int32 shift);
59 
60  static int SearchMultiplyList(char* pmul[9], bool exist[9], char* dividend, Int32 iDigits_dividend, char* divisor, Int32 iDigits_divisor);
61  static void GenMultiplyList(Int32 index, char* pmul[9], bool exist[9], char* divisor, Int32 iDigits);
62  static void Subtract4divide(char *pdividend, Int32 dividend_length, Int32 digits_divisor, char* mul[9], Int32 result);
63 
64  BigInt* Clone(MBase::Buffer *iBuffer, Int32 iSignum) const;
65 
66  static BigInt* CreateZero(MBase::Buffer *iBuffer);
67  };
68 
69 }
70 #endif // MDataType_BigInt_h
Definition: Buffer.h:58
Definition: BigDecimal.h:18
#define Int32
Definition: BasicTypes.h:20
Definition: BigDecimal.h:27
Definition: BigInt.h:24