mirror of
https://hub.njuu.cf/TheAlgorithms/C-Plus-Plus.git
synced 2023-10-11 13:05:55 +08:00
Type checks
This commit is contained in:
parent
a7ab392ace
commit
b032274df1
@ -197,7 +197,7 @@ class uint256_t {
|
|||||||
* @returns addition of this and p, returning uint256_t integer
|
* @returns addition of this and p, returning uint256_t integer
|
||||||
*/
|
*/
|
||||||
inline uint256_t operator+(const uint256_t &p) {
|
inline uint256_t operator+(const uint256_t &p) {
|
||||||
bool app = s + p.s < s;
|
uint32_t app = (s + p.s < s);
|
||||||
return {f + app + p.f, p.s + s};
|
return {f + app + p.f, p.s + s};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -210,7 +210,7 @@ class uint256_t {
|
|||||||
template <typename T, typename = typename std::enable_if<
|
template <typename T, typename = typename std::enable_if<
|
||||||
std::is_integral<T>::value, T>::type>
|
std::is_integral<T>::value, T>::type>
|
||||||
inline uint256_t &operator+=(const T &p) {
|
inline uint256_t &operator+=(const T &p) {
|
||||||
bool app = p + s < s;
|
uint32_t app = (p + s < s);
|
||||||
this->f += app;
|
this->f += app;
|
||||||
this->s += p;
|
this->s += p;
|
||||||
return *this;
|
return *this;
|
||||||
@ -222,7 +222,7 @@ class uint256_t {
|
|||||||
* @returns addition of this and p, returning this
|
* @returns addition of this and p, returning this
|
||||||
*/
|
*/
|
||||||
inline uint256_t &operator+=(const uint256_t &p) {
|
inline uint256_t &operator+=(const uint256_t &p) {
|
||||||
bool _app = (p.s + s < s);
|
uint32_t _app = (p.s + s < s);
|
||||||
f += _app + p.f;
|
f += _app + p.f;
|
||||||
s += p.s;
|
s += p.s;
|
||||||
return *this;
|
return *this;
|
||||||
@ -255,7 +255,7 @@ class uint256_t {
|
|||||||
template <typename T, typename = typename std::enable_if<
|
template <typename T, typename = typename std::enable_if<
|
||||||
std::is_integral<T>::value, T>::type>
|
std::is_integral<T>::value, T>::type>
|
||||||
inline uint256_t operator-(const T &p) {
|
inline uint256_t operator-(const T &p) {
|
||||||
bool app = p > s;
|
uint32_t app = (p > s);
|
||||||
return uint256_t(f - app, s - p);
|
return uint256_t(f - app, s - p);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -265,7 +265,7 @@ class uint256_t {
|
|||||||
* @returns subtraction of this and p, returning uint256_t integer
|
* @returns subtraction of this and p, returning uint256_t integer
|
||||||
*/
|
*/
|
||||||
inline uint256_t operator-(const uint256_t &p) {
|
inline uint256_t operator-(const uint256_t &p) {
|
||||||
bool app = p.s > s;
|
uint32_t app = p.s > s;
|
||||||
return {f - p.f - app, s - p.s};
|
return {f - p.f - app, s - p.s};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -302,7 +302,7 @@ class uint256_t {
|
|||||||
template <typename T, typename = typename std::enable_if<
|
template <typename T, typename = typename std::enable_if<
|
||||||
std::is_integral<T>::value, T>::type>
|
std::is_integral<T>::value, T>::type>
|
||||||
inline uint256_t operator-=(const T p) {
|
inline uint256_t operator-=(const T p) {
|
||||||
bool app = p > s;
|
uint32_t app = (p > s);
|
||||||
f -= app;
|
f -= app;
|
||||||
s -= p;
|
s -= p;
|
||||||
return *this;
|
return *this;
|
||||||
@ -314,7 +314,7 @@ class uint256_t {
|
|||||||
* @returns subtraction of this and p, returning this
|
* @returns subtraction of this and p, returning this
|
||||||
*/
|
*/
|
||||||
inline uint256_t &operator-=(const uint256_t &p) {
|
inline uint256_t &operator-=(const uint256_t &p) {
|
||||||
bool app = p.s > s;
|
uint32_t app = p.s > s;
|
||||||
f = f - app - p.f;
|
f = f - app - p.f;
|
||||||
s -= p.s;
|
s -= p.s;
|
||||||
return *this;
|
return *this;
|
||||||
|
Loading…
Reference in New Issue
Block a user