📄 64bit_integers.hpp
字号:
inline sinteger64::sinteger64(ss_sint32_t high, ss_sint32_t low)
: m_low(low)
, m_high(high)
{}
#ifdef STLSOFT_CF_INT_DISTINCT_INT_TYPE
inline sinteger64::sinteger64(int i)
: m_low(i)
, m_high(0)
{}
#endif /* STLSOFT_CF_INT_DISTINCT_INT_TYPE */
#ifdef STLSOFT_CF_LONG_DISTINCT_INT_TYPE
inline sinteger64::sinteger64(long i)
: m_low(i)
, m_high(0)
{}
#endif /* STLSOFT_CF_LONG_DISTINCT_INT_TYPE */
inline sinteger64::class_type &sinteger64::operator =(class_type const& rhs)
{
m_high = rhs.m_high;
m_low = rhs.m_low;
return *this;
}
inline sinteger64::class_type &sinteger64::operator =(ss_sint8_t i)
{
m_high = 0;
m_low = i;
return *this;
}
inline sinteger64::class_type &sinteger64::operator =(ss_sint16_t i)
{
m_high = 0;
m_low = i;
return *this;
}
inline sinteger64::class_type &sinteger64::operator =(ss_sint32_t i)
{
m_high = 0;
m_low = i;
return *this;
}
#ifdef STLSOFT_CF_INT_DISTINCT_INT_TYPE
inline sinteger64::class_type &sinteger64::operator =(int i)
{
m_high = 0;
m_low = i;
return *this;
}
#endif /* STLSOFT_CF_INT_DISTINCT_INT_TYPE */
#ifdef STLSOFT_CF_LONG_DISTINCT_INT_TYPE
inline sinteger64::class_type &sinteger64::operator =(long i)
{
m_high = 0;
m_low = i;
return *this;
}
#endif /* STLSOFT_CF_LONG_DISTINCT_INT_TYPE */
inline sinteger64::class_type &sinteger64::operator +=(class_type const& rhs)
{
m_low += rhs.m_low;
m_high += rhs.m_high;
if( rhs.m_low > 0 &&
m_low < rhs.m_low)
{
++m_high;
}
else if(rhs.m_low < 0 &&
m_low > rhs.m_low)
{
--m_high;
}
return *this;
}
inline sinteger64::class_type &sinteger64::operator +=(ss_sint8_t i)
{
return operator +=(class_type(i));
}
inline sinteger64::class_type &sinteger64::operator +=(ss_sint16_t i)
{
return operator +=(class_type(i));
}
inline sinteger64::class_type &sinteger64::operator +=(ss_sint32_t i)
{
return operator +=(class_type(i));
}
#ifdef STLSOFT_CF_INT_DISTINCT_INT_TYPE
inline sinteger64::class_type &sinteger64::operator +=(int i)
{
return operator +=(class_type(i));
}
#endif /* STLSOFT_CF_INT_DISTINCT_INT_TYPE */
#ifdef STLSOFT_CF_LONG_DISTINCT_INT_TYPE
inline sinteger64::class_type &sinteger64::operator +=(long i)
{
return operator +=(class_type(i));
}
#endif /* STLSOFT_CF_LONG_DISTINCT_INT_TYPE */
inline sinteger64::class_type &sinteger64::operator -=(class_type const& rhs)
{
m_low -= rhs.m_low;
m_high -= rhs.m_high;
if( rhs.m_low > 0 &&
m_low < rhs.m_low)
{
++m_high;
}
else if(rhs.m_low < 0 &&
m_low > rhs.m_low)
{
--m_high;
}
return *this;
}
inline sinteger64::class_type &sinteger64::operator -=(ss_sint8_t i)
{
return operator -=(class_type(i));
}
inline sinteger64::class_type &sinteger64::operator -=(ss_sint16_t i)
{
return operator -=(class_type(i));
}
inline sinteger64::class_type &sinteger64::operator -=(ss_sint32_t i)
{
return operator -=(class_type(i));
}
#ifdef STLSOFT_CF_INT_DISTINCT_INT_TYPE
inline sinteger64::class_type &sinteger64::operator -=(int i)
{
return operator -=(class_type(i));
}
#endif /* STLSOFT_CF_INT_DISTINCT_INT_TYPE */
#ifdef STLSOFT_CF_LONG_DISTINCT_INT_TYPE
inline sinteger64::class_type &sinteger64::operator -=(long i)
{
return operator -=(class_type(i));
}
#endif /* STLSOFT_CF_LONG_DISTINCT_INT_TYPE */
inline sinteger64::class_type &sinteger64::operator *=(class_type const& rhs)
{
m_low *= rhs.m_low;
m_high *= rhs.m_high;
if( rhs.m_low > 0 &&
m_low < rhs.m_low)
{
++m_high;
}
else if(rhs.m_low < 0 &&
m_low > rhs.m_low)
{
--m_high;
}
return *this;
}
inline sinteger64::class_type &sinteger64::operator *=(ss_sint8_t i)
{
return operator *=(class_type(i));
}
inline sinteger64::class_type &sinteger64::operator *=(ss_sint16_t i)
{
return operator *=(class_type(i));
}
inline sinteger64::class_type &sinteger64::operator *=(ss_sint32_t i)
{
return operator *=(class_type(i));
}
#ifdef STLSOFT_CF_INT_DISTINCT_INT_TYPE
inline sinteger64::class_type &sinteger64::operator *=(int i)
{
return operator *=(class_type(i));
}
#endif /* STLSOFT_CF_INT_DISTINCT_INT_TYPE */
#ifdef STLSOFT_CF_LONG_DISTINCT_INT_TYPE
inline sinteger64::class_type &sinteger64::operator *=(long i)
{
return operator *=(class_type(i));
}
#endif /* STLSOFT_CF_LONG_DISTINCT_INT_TYPE */
//inline sinteger64::class_type &sinteger64::operator /=(class_type const& rhs);
inline sinteger64::class_type &sinteger64::operator /=(ss_sint8_t i)
{
return operator /=(class_type(i));
}
inline sinteger64::class_type &sinteger64::operator /=(ss_sint16_t i)
{
return operator /=(class_type(i));
}
inline sinteger64::class_type &sinteger64::operator /=(ss_sint32_t i)
{
return operator /=(class_type(i));
}
#ifdef STLSOFT_CF_INT_DISTINCT_INT_TYPE
inline sinteger64::class_type &sinteger64::operator /=(int i)
{
return operator /=(class_type(i));
}
#endif /* STLSOFT_CF_INT_DISTINCT_INT_TYPE */
#ifdef STLSOFT_CF_LONG_DISTINCT_INT_TYPE
inline sinteger64::class_type &sinteger64::operator /=(long i)
{
return operator /=(class_type(i));
}
#endif /* STLSOFT_CF_LONG_DISTINCT_INT_TYPE */
//inline sinteger64::class_type &sinteger64::operator %=(class_type const& rhs);
inline sinteger64::class_type &sinteger64::operator %=(ss_sint8_t i)
{
return operator %=(class_type(i));
}
inline sinteger64::class_type &sinteger64::operator %=(ss_sint16_t i)
{
return operator %=(class_type(i));
}
inline sinteger64::class_type &sinteger64::operator %=(ss_sint32_t i)
{
return operator %=(class_type(i));
}
#ifdef STLSOFT_CF_INT_DISTINCT_INT_TYPE
inline sinteger64::class_type &sinteger64::operator %=(int i)
{
return operator %=(class_type(i));
}
#endif /* STLSOFT_CF_INT_DISTINCT_INT_TYPE */
#ifdef STLSOFT_CF_LONG_DISTINCT_INT_TYPE
inline sinteger64::class_type &sinteger64::operator %=(long i)
{
return operator %=(class_type(i));
}
#endif /* STLSOFT_CF_LONG_DISTINCT_INT_TYPE */
inline ss_sint_t sinteger64::compare(class_type const& rhs) const
{
ss_sint_t res = m_high - rhs.m_high;
if(0 == res)
{
res = m_low - rhs.m_low;
}
return res;
}
inline ss_sint_t sinteger64::compare(ss_sint8_t i) const
{
return compare(class_type(0, i));
}
inline ss_sint_t sinteger64::compare(ss_sint16_t i) const
{
return compare(class_type(0, i));
}
inline ss_sint_t sinteger64::compare(ss_sint32_t i) const
{
return compare(class_type(0, i));
}
#ifdef STLSOFT_CF_INT_DISTINCT_INT_TYPE
inline ss_sint_t sinteger64::compare(int i) const
{
return compare(class_type(0, i));
}
#endif /* STLSOFT_CF_INT_DISTINCT_INT_TYPE */
#ifdef STLSOFT_CF_LONG_DISTINCT_INT_TYPE
inline ss_sint_t sinteger64::compare(long i) const
{
return compare(class_type(0, i));
}
#endif /* STLSOFT_CF_LONG_DISTINCT_INT_TYPE */
#ifndef _STLSOFT_NO_NAMESPACE
} // namespace sinteger64_util
#endif /* _STLSOFT_NO_NAMESPACE */
#endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
/* ////////////////////////////////////////////////////////////////////// */
#ifndef _STLSOFT_NO_NAMESPACE
} // namespace stlsoft
#endif /* _STLSOFT_NO_NAMESPACE */
/* ////////////////////////////////////////////////////////////////////// */
#endif /* !STLSOFT_INCL_STLSOFT_UTIL_HPP_64BIT_INTEGERS */
/* ////////////////////////////////////////////////////////////////////// */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -