- /* sninline.h by K.Tsuru */
- #ifndef SN_INLINE_H
- #define SN_INLINE_H
- /***************************************************************
- inline functions comparing operator for SLong and SDouble
- neither not member nor friend functions.
- Note that XXCompare(m, n) for |m| and |n|.
- ****************************************************************/
- /*****************************
- operator for SLong class
- ******************************/
- // Return values are changed "int" to "bool" type. ver.2.17
- // relational operator
- // LLCompare(m, n) = sgn(|m| - |n|)
- inline bool operator>(const SLong& m, const SLong& n){
- if(m.Sign() != n.Sign()) return m.Sign() > n.Sign();
- return (LLCompare(m, n) * m.Sign()) > 0;
- }
- inline bool operator<(const SLong& m, const SLong& n){
- if(m.Sign() != n.Sign()) return m.Sign() < n.Sign();
- return (LLCompare(m, n) * m.Sign()) < 0;
- }
- inline bool operator==(const SLong& m, const SLong& n){
- if(m.Sign() != n.Sign()) return false; // ver. 2.17
- return LLCompare(m, n) == 0;
- }
- inline bool operator!=(const SLong& m, const SLong& n){
- return !(m == n);
- }
- inline bool operator>=(const SLong& m, const SLong& n){
- if(m.Sign() != n.Sign()) return m.Sign() > n.Sign();
- return (LLCompare(m, n) * m.Sign()) >= 0;
- // return (m > n) || (m == n); LLCompare() is called twice.
- }
- inline bool operator<=(const SLong& m, const SLong& n){
- if(m.Sign() != n.Sign()) return m.Sign() < n.Sign();
- return (LLCompare(m, n) * m.Sign()) <= 0;
- // return (m < n) || (m == n);
- }
- inline bool operator==(const Ldiv_t& m, const Ldiv_t& n){
- return (m.quot == n.quot) && (m.rem == n.rem);
- }
- inline bool operator!=(const Ldiv_t& m, const Ldiv_t& n){
- return !(m == n);
- }
- /*****************************
- operator for SDouble class
- ******************************/
- // relational operator
- inline bool operator>(const SDouble& m, const SDouble& n){
- if(m.Sign() != n.Sign()) return m.Sign() > n.Sign();
- return (DDCompare(m, n) * m.Sign()) > 0;
- }
- inline bool operator<(const SDouble& m, const SDouble& n){
- if(m.Sign() != n.Sign()) return m.Sign() < n.Sign();
- return (DDCompare(m, n) * m.Sign()) < 0;
- }
- inline bool operator==(const SDouble& m, const SDouble& n){
- if(m.Sign() != n.Sign()) return false; // ver. 2.17
- return DDCompare(m, n) == 0;
- }
- inline bool operator!=(const SDouble& m, const SDouble& n){
- return !(m == n);
- }
- inline bool operator>=(const SDouble& m, const SDouble& n){
- if(m.Sign() != n.Sign()) return m.Sign() > n.Sign();
- return (DDCompare(m, n) * m.Sign()) >= 0;
- // return (m > n) || (m == n);
- }
- inline bool operator<=(const SDouble& m, const SDouble& n){
- if(m.Sign() != n.Sign()) return m.Sign() < n.Sign();
- return (DDCompare(m, n) * m.Sign()) <= 0;
- // return (m < n) || (m == n);
- }
-
- // returns ceil( log10(x) ) ver.2.18
- inline long CeilLog10(const SLong& x) {
- return x.DFigures();
- }
- inline long CeilLog10(const SDouble& x) {
- return x.DExp();
- }
-
- /***************************************
- logical functions for SNumber class
- derived classes can use
- ***************************************/
- inline bool operator||(const SNumber& m, const SNumber& n){
- return (m.Sign() || n.Sign());
- }
- inline bool operator&&(const SNumber& m, const SNumber& n){
- return (m.Sign() && n.Sign());
- }
- inline bool operator!(const SNumber& m){ return !m.Sign(); }
- #endif // SN_INLINE_H
sninline.h : last modifiled at 2016/01/08 14:40:46(3,371 bytes)
created at 2016/04/11 11:18:59
The creation time of this html file is 2017/10/11 16:07:52 (Wed Oct 11 16:07:52 2017).