Changeset 1117


Ignore:
Timestamp:
Aug 6, 2003, 10:18:36 PM (17 years ago)
Author:
orlov
Message:
  • Added methods for comparison with long int and conversion to it.
Location:
to-imperative/trunk/runtime
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • to-imperative/trunk/runtime/rf_integer.hh

    r1035 r1117  
    2929
    3030  inline bool operator == (Integer const& _n) const ;
     31  inline bool operator == (intptr_t _n) const ;
    3132  inline int cmp (Integer const& _n) const ;
     33  inline int cmp (intptr_t _n) const ;
    3234
    3335  inline Integer operator + (Integer const& _n) const ;
     
    5254  inline Integer operator - () const ;
    5355  inline int sign () const ;
     56
     57  inline long to_int () const ;
    5458
    5559  inline operator pxx::WString () const ;
  • to-imperative/trunk/runtime/rf_integer.ih

    r1082 r1117  
    8989}
    9090
     91inline bool Integer::operator == (intptr_t _n) const
     92{
     93  mpz_t* p = static_cast<mpz_t*>(ptr_data2);
     94  return mpz_cmp_si(*p, _n) == 0;
     95}
     96
    9197inline int Integer::cmp (Integer const& _n) const
    9298{
     
    94100  mpz_t* q = static_cast<mpz_t*>(_n.ptr_data2);
    95101  return mpz_cmp(*p, *q);
     102}
     103
     104inline int Integer::cmp (intptr_t _n) const
     105{
     106  mpz_t* p = static_cast<mpz_t*>(ptr_data2);
     107  return mpz_cmp_si(*p, _n);
    96108}
    97109
     
    272284}
    273285
     286inline long Integer::to_int () const
     287{
     288  return mpz_get_si(*(get_mpz_ptr()));
     289}
     290
    274291inline Integer::operator pxx::WString () const
    275292{
Note: See TracChangeset for help on using the changeset viewer.