octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: bitshift of int8, int16, etc?


From: Daniel J Sebald
Subject: Re: bitshift of int8, int16, etc?
Date: Sun, 24 Jun 2007 21:29:58 -0500
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.3) Gecko/20041020

Daniel J Sebald wrote:
  template <class T2>
  octave_int<T>& operator <<= (const T2& x)
  {
    ival = ival << x;
    if (ival > std::numeric_limits<T>::max ())
    ival &= std::numeric_limits<T>::max ();
    else if (ival < std::numeric_limits<T>::min ())
    ival |= std::numeric_limits<T>::min ();
    return *this;
  }
[snip]
It all depends how behavior is defined. I'm not 100% sure what it should be defined as.

With that in mind, I should say that what I was attempting in the above is to 
simulate what would happen if your CPU were 8 bits wide.

Dan


reply via email to

[Prev in Thread] Current Thread [Next in Thread]