DATRW++ library: seismic data I/O with multiple formats

◆ extract()

int datrw::mseed::SEED::Steim2Word::extract ( const int &  b,
const int &  p 
) const
private

return masked value

  • b number of bits
  • p position in word

Definition at line 375 of file seedstructs.cc.

References DATRW_assert, Mword, and value().

Referenced by value().

376  {
377  DATRW_assert((b>0), "ERROR (Steim2Word::extract): "
378  "use at least 1 byte");
379  DATRW_assert((p>=0), "ERROR (Steim2Word::extract): "
380  "illegal position");
381  DATRW_assert((p<int(32/b)), "ERROR (Steim2Word::extract): "
382  "illegal position");
383  int signmask=int(1 << (b-1));
384  int valmask=signmask - 1;
385  int nshift=b*p;
386  // extract sign bit
387  int sign=int((Mword >> nshift) & signmask);
388  // extract value bit code
389  int value=int((Mword >> nshift) & valmask);
390  // construct 32-bit (int size) two's complement value
391  int retval= sign ? (value | ~valmask) : value;
392  return(retval);
393  } // int Steim2Word::extract(const int& p) const
#define DATRW_assert(C, M)
Check an assertion and report by throwing an exception.
Definition: error.h:92
int value(const int &i) const
Definition: seedstructs.cc:317
Here is the call graph for this function:
Here is the caller graph for this function: