Teuchos - Trilinos Tools Package  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Teuchos_BigUIntDecl.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Teuchos: Common Tools Package
4 //
5 // Copyright 2004 NTESS and the Teuchos contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef TEUCHOS_BIG_UINT_DECL_HPP
11 #define TEUCHOS_BIG_UINT_DECL_HPP
12 
13 #include <iosfwd>
14 #include <cstdint>
15 
20 namespace Teuchos {
21 
33 template <int n>
34 class BigUInt {
35  private:
36  std::uint32_t x[n];
37  public:
38  BigUInt();
39  BigUInt(std::uint64_t v);
40  BigUInt(std::string const& s);
41  explicit operator bool() const noexcept;
42  std::uint32_t& operator[](int i);
43  std::uint32_t const& operator[](int i) const;
44  BigUInt& operator+=(std::uint32_t b);
45  BigUInt& operator+=(BigUInt const& b);
46  BigUInt& operator-=(std::uint32_t b);
47  BigUInt& operator-=(BigUInt const& b);
48  BigUInt& operator*=(std::uint32_t b);
49  BigUInt& operator<<=(std::uint32_t b);
50  BigUInt& operator>>=(std::uint32_t b);
51 };
52 
53 template <int n>
54 std::ostream& operator<<(std::ostream& os, BigUInt<n> a);
55 template <int n>
56 BigUInt<n> operator+(BigUInt<n> const& a, BigUInt<n> const& b);
57 template <int n>
58 BigUInt<n> operator-(BigUInt<n> const& a, BigUInt<n> const& b);
59 template <int n>
60 BigUInt<n> operator*(BigUInt<n> const& a, BigUInt<n> const& b);
61 template <int n>
62 BigUInt<n> operator/(BigUInt<n> const& a, std::uint32_t const& b);
63 template <int n>
64 BigUInt<n> operator/(BigUInt<n> const& a, BigUInt<n> const& b);
65 template <int n>
66 int comp(BigUInt<n> const& a, BigUInt<n> const& b);
67 template <int n>
68 bool operator>=(BigUInt<n> const& a, BigUInt<n> const& b);
69 template <int n>
70 bool operator<=(BigUInt<n> const& a, BigUInt<n> const& b);
71 template <int n>
72 bool operator<(BigUInt<n> const& a, BigUInt<n> const& b);
73 template <int n>
74 bool operator>(BigUInt<n> const& a, BigUInt<n> const& b);
75 template <int n>
76 bool operator==(BigUInt<n> const& a, BigUInt<n> const& b);
77 template <int n>
78 void divmod(BigUInt<n>& quotient, BigUInt<n>& x, std::uint32_t const& b);
79 
80 }
81 
82 #endif
Arbitrary-precision unsigned integer class.