Advanced Multi-Physics (AMP)
On-Line Documentation
extended_int.h
Go to the documentation of this file.
1#ifndef included_extended_int
2#define included_extended_int
3
4#include <array>
5#include <cstdint>
6#include <limits>
7#include <stdint.h>
8#include <stdlib.h>
9#include <string>
10
11#include "AMP/utils/UtilityMacros.h"
12
13
14namespace AMP::extended {
15
16
21template<uint8_t N>
22class alignas( 8 ) int64N
23{
24public:
26 constexpr int64N();
27
29 constexpr int64N( const int64N & ) = default;
30
32 constexpr int64N<N> &operator=( const int64N<N> & ) = default;
33
35 constexpr int64N( int64N && ) = default;
36
38 constexpr int64N<N> &operator=( int64N<N> && ) = default;
39
41 explicit constexpr int64N( int rhs );
42
44 explicit constexpr int64N( int64_t );
45
47 explicit constexpr int64N( uint64_t );
48
50#ifdef __SIZEOF_INT128__
52 explicit constexpr int64N( __int128 );
53 explicit constexpr int64N( unsigned __int128 );
55#endif
56
58 template<uint8_t N2>
59 explicit constexpr int64N( const int64N<N2> & );
60
62 explicit constexpr int64N( const char * );
63
65 constexpr operator int() const;
66
68 constexpr operator int64_t() const;
69
71 constexpr operator float() const;
72
74 constexpr operator double() const;
75
77 constexpr operator long double() const;
78
80 constexpr operator bool() const;
81
83 std::string decimal() const;
84
86 constexpr std::array<char, 16 * N + 3> hex( bool fixedWidth = true ) const;
87
89 inline operator std::string() const { return hex().data(); }
90
92 constexpr int64N operator!() const;
93 constexpr int64N &operator+=( const int64N & );
94 constexpr int64N &operator+=( const int64_t );
95 constexpr int64N &operator+=( const uint64_t );
96 constexpr int64N &operator-=( const int64N & );
97 constexpr int64N &operator*=( const int64N & );
98 constexpr int64N &operator/=( const int64N & );
99
101 constexpr bool operator==( const int64N & ) const;
102 constexpr bool operator!=( const int64N & ) const;
103 constexpr bool operator>( const int64N & ) const;
104 constexpr bool operator<( const int64N & ) const;
105 constexpr bool operator>=( const int64N & ) const;
106 constexpr bool operator<=( const int64N & ) const;
107 constexpr bool operator==( int ) const;
108 constexpr bool operator!=( int ) const;
109 constexpr bool operator>( int ) const;
110 constexpr bool operator<( int ) const;
111 constexpr bool operator>=( int ) const;
112 constexpr bool operator<=( int ) const;
113
115 constexpr int sign() const;
116
118 constexpr void compliment();
119
121 double log2() const;
122
124 inline double log10() const { return 0.301029995663981 * log2(); }
125
127 constexpr int64N &operator<<=( unsigned );
128 constexpr int64N &operator>>=( unsigned );
129
130protected:
131 uint64_t data[N];
132
133 template<uint8_t N2>
134 friend class int64N;
135};
136
137
138// Define some types
144
145
146// Arithmetic operator overloading
147template<uint8_t N>
148constexpr int64N<N> operator+( const int64N<N> &x, const int64N<N> &y );
149template<uint8_t N>
150constexpr int64N<N> operator-( const int64N<N> &x, const int64N<N> &y );
151template<uint8_t N>
152constexpr int64N<N> operator*( const int64N<N> &x, const int64N<N> &y );
153template<uint8_t N>
154constexpr int64N<N> operator/( const int64N<N> &x, const int64N<N> &y );
155template<uint8_t N>
156constexpr int64N<N> operator-( const int64N<N> &x );
157template<uint8_t N>
158constexpr int64N<N> operator-( const int64_t &x, const int64N<N> &y );
159
160
161// ostream
162template<uint8_t N>
163std::ostream &operator<<( std::ostream &out, const int64N<N> &x );
164
165
166// bitshift operators
167template<uint8_t N>
168constexpr int64N<N> operator<<( const int64N<N> &, const int );
169template<uint8_t N>
170constexpr int64N<N> operator>>( const int64N<N> &, const int );
171} // namespace AMP::extended
172
173
174// numeric_limits
175namespace std {
176template<uint8_t N>
177class numeric_limits<AMP::extended::int64N<N>>
178{
179public: // Member constants
180 static constexpr bool is_specialized = true;
181 static constexpr bool is_signed = true;
182 static constexpr bool is_integer = true;
183 static constexpr bool is_exact = true;
184 static constexpr bool has_infinity = false;
185 static constexpr bool has_quiet_NaN = false;
186 static constexpr bool has_signaling_NaN = false;
187 static constexpr float_denorm_style has_denorm = denorm_absent;
188 static constexpr bool has_denorm_loss = false;
189 static constexpr float_round_style round_style = round_toward_zero;
190 static constexpr bool is_iec559 = false;
191 static constexpr bool is_bounded = true;
192 static constexpr bool is_modulo = false;
193 static constexpr int digits = 64 * N - 1;
194 static constexpr int digits10 = ( 64 * N - 1 ) * 0.301029995663981;
195 static constexpr int max_digits10 = 0;
196 static constexpr int radix = 2;
197 static constexpr int min_exponent = 0;
198 static constexpr int min_exponent10 = 0;
199 static constexpr int max_exponent = 0;
200 static constexpr int max_exponent10 = 0;
201 static constexpr bool traps = true;
202 static constexpr bool tinyness_before = false;
203
204public: // Member functions
205 static constexpr AMP::extended::int64N<N> min() noexcept
206 {
207 return AMP::extended::int64N<N>( 1 ) << 64 * N - 1;
208 }
209 static constexpr AMP::extended::int64N<N> lowest() noexcept { return min(); }
210 static constexpr AMP::extended::int64N<N> max() noexcept { return !min(); }
211 static constexpr AMP::extended::int64N<N> epsilon() noexcept
212 {
214 }
215 static constexpr AMP::extended::int64N<N> round_error() noexcept { return 0; }
216 static constexpr AMP::extended::int64N<N> infinity() noexcept { return 0; }
217 static constexpr AMP::extended::int64N<N> quiet_NaN() noexcept { return 0; }
218 static constexpr AMP::extended::int64N<N> signaling_NaN() noexcept { return 0; }
219 static constexpr AMP::extended::int64N<N> denorm_min() noexcept { return 0; }
220};
221
222
223} // namespace std
224
225
226#include "AMP/utils/extended_int.hpp"
227
228#endif
constexpr bool operator<(const int64N &) const
constexpr int64N & operator-=(const int64N &)
constexpr int64N(int rhs)
Create from int.
constexpr bool operator<=(int) const
constexpr int64N & operator/=(const int64N &)
constexpr int64N & operator+=(const uint64_t)
constexpr int64N(int64_t)
Create from int64.
constexpr int64N()
Empty constructor.
constexpr bool operator>=(int) const
constexpr int64N & operator+=(const int64N &)
constexpr void compliment()
Convert to the 2's compliment of the number (equivalent to multiplying by -1)
constexpr int64N(int64N &&)=default
Move constructor.
constexpr int64N(const int64N &)=default
Copy constructor.
double log10() const
Calculate the log base 2.
constexpr std::array< char, 16 *N+3 > hex(bool fixedWidth=true) const
Get the hexadecimal number as a char array.
constexpr bool operator==(const int64N &) const
Overload comparison operators.
constexpr int64N & operator<<=(unsigned)
Bitshift operators.
constexpr bool operator<(int) const
constexpr bool operator==(int) const
constexpr int sign() const
Get the sign of the number.
constexpr int64N< N > & operator=(const int64N< N > &)=default
Assignment operator.
constexpr int64N & operator*=(const int64N &)
constexpr bool operator>=(const int64N &) const
constexpr int64N & operator>>=(unsigned)
constexpr int64N & operator+=(const int64_t)
constexpr bool operator>(int) const
constexpr bool operator<=(const int64N &) const
constexpr int64N(const int64N< N2 > &)
Create from int128.
constexpr int64N(uint64_t)
Create from int64.
constexpr int64N operator!() const
Overload arimetic operators.
constexpr int64N(const char *)
Create from string.
constexpr int64N< N > & operator=(int64N< N > &&)=default
Move operator.
std::string decimal() const
Get the hexadecimal number as a char array.
constexpr bool operator!=(int) const
constexpr bool operator!=(const int64N &) const
constexpr bool operator>(const int64N &) const
double log2() const
Calculate the log base 2.
static constexpr AMP::extended::int64N< N > min() noexcept
static constexpr AMP::extended::int64N< N > signaling_NaN() noexcept
static constexpr AMP::extended::int64N< N > quiet_NaN() noexcept
static constexpr AMP::extended::int64N< N > denorm_min() noexcept
static constexpr AMP::extended::int64N< N > max() noexcept
static constexpr AMP::extended::int64N< N > round_error() noexcept
static constexpr AMP::extended::int64N< N > infinity() noexcept
static constexpr AMP::extended::int64N< N > lowest() noexcept
static constexpr AMP::extended::int64N< N > epsilon() noexcept
#define DISABLE_WARNINGS
Re-enable warnings.
#define ENABLE_WARNINGS
Suppress all warnings.
constexpr int64N< N > operator*(const int64N< N > &x, const int64N< N > &y)
constexpr int64N< N > operator+(const int64N< N > &x, const int64N< N > &y)
constexpr int64N< N > operator-(const int64N< N > &x, const int64N< N > &y)
int64N< 32 > int2048_t
int64N< 4 > int256_t
int64N< 8 > int512_t
constexpr int64N< N > operator/(const int64N< N > &x, const int64N< N > &y)
constexpr int64N< N > operator>>(const int64N< N > &, const int)
int64N< 16 > int1024_t
std::ostream & operator<<(std::ostream &out, const int64N< N > &x)
int64N< 2 > int128_t



Advanced Multi-Physics (AMP)
Oak Ridge National Laboratory
Idaho National Laboratory
Los Alamos National Laboratory
This page automatically produced from the
source code by doxygen
Last updated: Tue Mar 10 2026 13:06:41.
Comments on this page