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

◆ adjustscale()

void datrw::su::ScalCoo::adjustscale ( )

adjust scale to optimal representation of significant digits

This function removes trailing zeroes from the ScalCoo::coo value, by chosing an appropriate scale value. Upon return from this function the scale power is as large as possible. Any increase in the power of the scale value will result in truncation of the coordinate value.

Definition at line 276 of file sucomanager.cc.

References coo, DATRW_assert, power(), datrw::su::powertoscale(), and scale.

Referenced by main().

277  {
278  int p=this->power();
279  int v1, v2;
280  do {
281  v1=this->coo;
282  v2=std::floor(v1/10)*10;
283  if ((v1==v2) && (p<4))
284  {
285  ++p;
286  this->coo /= 10;
287  }
288  } while ((v1==v2) && (p<4));
289  this->scale=powertoscale(p);
290  DATRW_assert(this-scale != 0,
291  "ERROR (ScalCoo::scaletopower): illegal scale value!");
292  } // void ScalCoo::adjustscale()
#define DATRW_assert(C, M)
Check an assertion and report by throwing an exception.
Definition: error.h:92
int coo
coordinate
Definition: sucomanager.h:171
short scale
scale like scalco
Definition: sucomanager.h:169
short powertoscale(const int &p)
convert a decimal power to a SeismicUn*x scale value
Definition: sucomanager.cc:474
int power() const
return decimal power of scaling factor
Definition: sucomanager.cc:230
Here is the call graph for this function:
Here is the caller graph for this function: