#include <iomanip>
#include <sstream>
#include "Rtypes.h"
#include "TMemStatHelpers.h"
using namespace std;
string Memstat::dig2bytes(Long64_t bytes)
{
   
   
   
   ostringstream ss;
   ss << fixed;
   if (bytes < 0) {
      ss << '-';
      bytes = -bytes;
   }
   static const long kB = 1024L;
   static const long lMB = kB * kB;
   static const long lGB = lMB * kB;
   if (bytes < kB)
      ss << bytes << " B";
   else if (bytes < (10L * kB))
      ss << setprecision(2) << ((double)bytes / (float)kB) << " kB";
   else if (bytes < (100L * kB))
      ss << setprecision(1) << ((double)bytes / (float)kB) << " kB";
   else if (bytes < lMB)
      ss << setprecision(0) << ((double)bytes / (float)kB) << " kB";
   else if (bytes < (10L * lMB))
      ss << setprecision(2) << ((double)bytes / (float)lMB) << " MB";
   else if (bytes < (100L * lMB))
      ss << setprecision(1) << ((double)bytes / (float)lMB) << " MB";
   else if (bytes < lGB)
      ss << setprecision(0) << ((double)bytes / (float)lMB) << " MB";
   else
      ss << setprecision(2) << ((double)bytes / (float)lGB) << " GB";
   return ss.str();
}
Last change: Wed Jun 25 08:29:11 2008
Last generated: 2008-06-25 08:29
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.