File: LargeInt.h

package info (click to toggle)
mapsembler2 2.2.4%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 8,208 kB
  • sloc: cpp: 51,300; ansic: 13,434; sh: 483; makefile: 394; asm: 271; python: 28
file content (48 lines) | stat: -rw-r--r-- 1,253 bytes parent folder | download | duplicates (13)
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
/*
 * arbitrary-precision integer library
 * very limited: only does what minia needs (but not what minia deserves)
 */

#ifndef LargeInt_h
#define LargeInt_h

#include <stdint.h>
#include <algorithm>

template<int precision>
class LargeInt 
{

    public:
    uint64_t array[precision];
    LargeInt(const uint64_t &);
    LargeInt();

    // overloading
    LargeInt operator+(const LargeInt &) const;
    LargeInt operator-(const LargeInt &) const;
    LargeInt operator*(const int &) const;
    LargeInt operator/(const uint32_t &) const;
    uint32_t operator%(const uint32_t &) const;
    LargeInt operator^(const LargeInt &) const;
    LargeInt operator&(const LargeInt &) const;
    LargeInt operator~() const;
    LargeInt operator<<(const int &) const;
    LargeInt operator>>(const int &) const;
    bool     operator!=(const LargeInt &) const;
    bool     operator==(const LargeInt &) const;
    bool     operator<(const LargeInt &) const;
    bool     operator<=(const LargeInt &) const;

    // custom
    uint64_t toInt() const;
    #ifdef _LP64
    __uint128_t toInt128() const;
    #endif


// c++ fun fact:
// "const" will ban the function from being anything which can attempt to alter any member variables in the object.
};

#endif