GSE++ library: reading and writing GSE waveforms

◆ add()

void GSE2::waveform::TCHK2::add ( const intT value)

Add a value to the checksum.

This function adds the sample value to the checksum.

Parameters
valuesample value to add

Definition at line 77 of file gsexx_TCHK2.cc.

References GSE2::waveform::helper::abs(), Msum, and value().

Referenced by GSE2::waveform::TDAT2sum::add(), and GSE2::tests::test_chk2().

78 {
79  const intT modulo=100000000; // a one and eight zeros
80  intT sample_value=value;
81 
82  // check for sample value overflow
83  if (helper::abs(sample_value) >= modulo)
84  {
85  sample_value = sample_value - int(sample_value/modulo)*modulo;
86  }
87 
88  // add the sample value to the checksum
89  Msum += sample_value;
90 
91  // check for checksum overflow
92  if (helper::abs(Msum) >= modulo)
93  {
94  Msum = Msum - int(Msum/modulo)*modulo;
95  }
96 }
int intT
All GSE2 waveform data is based on 4 byte integers.
Definition: gsexx.h:89
intT abs(const intT &val)
abs for intT
Definition: gsexx_TCHK2.cc:53
intT Msum
checksum value
Definition: gsexx.h:191
intT value() const
Return the checksum value.
Definition: gsexx.h:181
Here is the call graph for this function:
Here is the caller graph for this function: