Welcome to mirror list, hosted at ThFree Co, Russian Federation.

int64.hpp « Original « Rar29 « Compress « 7zip - github.com/kornelski/7z.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: a8057522e4f566bbe0008667746a15806edf5d2b (plain)
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#ifndef _RAR_INT64_
#define _RAR_INT64_

#if defined(__BORLANDC__) || defined(_MSC_VER)
#define NATIVE_INT64
typedef __int64 Int64;
#endif

#if defined(__GNUC__) || defined(__HP_aCC)
#define NATIVE_INT64
typedef long long Int64;
#endif

#ifdef NATIVE_INT64

#define int64to32(x) ((uint)(x))
#define int32to64(high,low) ((((Int64)(high))<<32)+(low))
#define is64plus(x) (x>=0)

#else

class Int64
{
  public:
    Int64();
    Int64(uint n);
    Int64(uint HighPart,uint LowPart);

//    Int64 operator = (Int64 n);
    Int64 operator << (int n);
    Int64 operator >> (int n);

    friend Int64 operator / (Int64 n1,Int64 n2);
    friend Int64 operator * (Int64 n1,Int64 n2);
    friend Int64 operator % (Int64 n1,Int64 n2);
    friend Int64 operator + (Int64 n1,Int64 n2);
    friend Int64 operator - (Int64 n1,Int64 n2);
    friend Int64 operator += (Int64 &n1,Int64 n2);
    friend Int64 operator -= (Int64 &n1,Int64 n2);
    friend Int64 operator *= (Int64 &n1,Int64 n2);
    friend Int64 operator /= (Int64 &n1,Int64 n2);
    friend Int64 operator | (Int64 n1,Int64 n2);
    friend Int64 operator & (Int64 n1,Int64 n2);
    inline friend void operator -= (Int64 &n1,unsigned int n2)
    {
      if (n1.LowPart<n2)
        n1.HighPart--;
      n1.LowPart-=n2;
    }
    inline friend void operator ++ (Int64 &n)
    {
      if (++n.LowPart == 0)
        ++n.HighPart;
    }
    inline friend void operator -- (Int64 &n)
    {
      if (n.LowPart-- == 0)
        n.HighPart--;
    }
    friend bool operator == (Int64 n1,Int64 n2);
    friend bool operator > (Int64 n1,Int64 n2);
    friend bool operator < (Int64 n1,Int64 n2);
    friend bool operator != (Int64 n1,Int64 n2);
    friend bool operator >= (Int64 n1,Int64 n2);
    friend bool operator <= (Int64 n1,Int64 n2);

    void Set(uint HighPart,uint LowPart);
    uint GetLowPart() {return(LowPart);}

    uint LowPart;
    uint HighPart;
};

inline uint int64to32(Int64 n) {return(n.GetLowPart());}
#define int32to64(high,low) (Int64((high),(low)))
#define is64plus(x) ((int)(x).HighPart>=0)

#endif

#define INT64ERR int32to64(0x80000000,0)
#define INT64MAX int32to64(0x7fffffff,0)

void itoa(Int64 n,char *Str);
Int64 atoil(char *Str);

#endif