Logo Search packages:      
Sourcecode: ktechlab version File versions  Download package

QString Item::getNumberMag ( double  num  )  [static, inherited]

Returns the SI exponent of the number as a letter: eg 10000 returns 'k', 0.6 returns 'm', etc

Definition at line 485 of file item.cpp.

Referenced by Variant::displayString(), and DoubleSpinBox::updateSuffix().

{
      if ( num == 0. ) return "";
      const double exp_n = std::log10(std::abs(num));
      if ( exp_n < minPrefixExp+3 ) return SIprefix[0];
      else if ( exp_n >= maxPrefixExp ) return SIprefix[numPrefix-1];
      else return SIprefix[(int)std::floor((double)(exp_n/3))-(int)floor(double(minPrefixExp/3))];
}


Generated by  Doxygen 1.6.0   Back to index