當前位置: 首頁>>代碼示例>>C++>>正文


C++ std::atof方法代碼示例

本文整理匯總了C++中std::atof方法的典型用法代碼示例。如果您正苦於以下問題:C++ std::atof方法的具體用法?C++ std::atof怎麽用?C++ std::atof使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在std的用法示例。


在下文中一共展示了std::atof方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。

示例1: getEnergyAndVirial

/* ********************************************************************************************* */
void getEnergyAndVirial(ifstream &ifil,solreal &theener,solreal &thevir)
{
   string line;
   getline(ifil,line);
   int pos;
   pos=line.find_first_of('=');
   line.erase(0,pos+1);
   while (line[0]==' ') {line.erase(0,1);}
   pos=line.find_first_of(' ');
   theener=(solreal)atof((line.substr(0,pos)).c_str());
   pos=line.find_first_of('=');
   line.erase(0,pos+1);
   while (line[0]==' ') {line.erase(0,1);}
   thevir=(solreal)atof(line.c_str());
}
開發者ID:jmsolano,項目名稱:denstoolkit,代碼行數:16,代碼來源:iofuncts-wfn.cpp

示例2: Set

void CONFIGVARIABLE::Set(string newval)
{
	newval = strTrim(newval);
	
	val_i = atoi(newval.c_str());
	val_f = atof(newval.c_str());
	val_s = newval;
	
	val_b = false;
	if (val_i == 0)
		val_b = false;
	if (val_i == 1)
		val_b = true;
	if (strLCase(newval) == "true")
		val_b = true;
	if (strLCase(newval) == "false")
		val_b = false;
	if (strLCase(newval) == "on")
		val_b = true;
	if (strLCase(newval) == "off")
		val_b = false;
	
	//now process as vector information
	int pos = 0;
	int arraypos = 0;
	string::size_type nextpos = newval.find(",", pos);
	string frag;
	
	while (nextpos < /*(int)*/ newval.length() && arraypos < 3)
	{
		frag = newval.substr(pos, nextpos - pos);
		val_v[arraypos] = atof(frag.c_str());
		
		pos = nextpos+1;
		arraypos++;
		nextpos = newval.find(",", pos);
	}
	
	//don't forget the very last one
	if (arraypos < 3)
	{
		frag = newval.substr(pos, newval.length() - pos);
		val_v[arraypos] = atof(frag.c_str());
	}
}
開發者ID:VDrift,項目名稱:pacejka,代碼行數:45,代碼來源:configfile.cpp

示例3: fin

VoxelBuffer * VoxelBuffer::factory(const string& filename)
{
	ifstream fin(filename);
	string inputBuffer;
	VoxelBuffer * tempBuffer;

	fin >> inputBuffer;		// "DELT"
	fin >> inputBuffer;		// Delta value
	float delta = (float)atof(inputBuffer.c_str());

	fin >> inputBuffer;		// "XYZC"
	fin >> inputBuffer;
	ivec3 dimensions;
	dimensions.x = atoi(inputBuffer.c_str());
	fin >> inputBuffer;
	dimensions.y = atoi(inputBuffer.c_str());
	fin >> inputBuffer;
	dimensions.z = atoi(inputBuffer.c_str());

	tempBuffer = new VoxelBuffer(delta, dimensions);
	float tempDensity/*, tempLight*/;		// Omit reading in lights temporarily
	voxel tempVoxel;
	int voxelBufferSize = dimensions.x * dimensions.y * dimensions.z;
	tempBuffer->voxels = new voxel[voxelBufferSize];
	int i = 0;

	// Read in voxel densities (and lights...later)
	while (!fin.eof()) {
		fin >> inputBuffer;
		tempDensity = (float)atof(inputBuffer.c_str());
		tempVoxel.density = tempDensity;
		tempVoxel.light = -1.0;
		tempBuffer->voxels[i++] = tempVoxel;	// Add voxel to the 1D array
	}

	return tempBuffer;
}
開發者ID:aaronr93,項目名稱:VoxelBuffer,代碼行數:37,代碼來源:VoxelBuffer.cpp

示例4: last_in_line

double last_in_line(const string& str)
{
    typedef string::const_iterator iter;
    vector<string> ret;
    
    iter i = str.begin();
    while (i != str.end()) {
        i = find_if(i, str.end(), not_space);
        iter j = find_if(i, str.end(), space);
        
        if (i != str.end())
            ret.push_back(string(i, j));
        i = j;
    }
    return atof(ret[ret.size() - 1].c_str());
}
開發者ID:adelbertc,項目名稱:misc,代碼行數:16,代碼來源:cdf.cpp

示例5: processMolecularOrbitalPropsAndCoefs

/* ********************************************************************************************* */
void processMolecularOrbitalPropsAndCoefs(ifstream &ifil,const int norb,const int npr
                                 ,solreal* &ocn,solreal* &moe,solreal* &moc)
{
   alloc1DRealArray("moc",(norb*npr),moc);
   alloc1DRealArray("ocn",norb,ocn);
   alloc1DRealArray("moe",norb,moe);
   int pos;
   /* Getting the molecular orbital occupation number, energies, and coefficients */
   string line;
   int count=0;
   int nolines;
   nolines=floor(npr/5);
   //cout << "npr: " << npr << " nolines: " << npr/5 << endl;
   if ((npr%5)>0) {nolines++;}
   for (int k=0; k<norb; k++) {
      pos=ifil.tellg();
      ifil.seekg(pos+35);
      ifil >> ocn[k];
      ifil.seekg(pos+63);
      ifil >> moe[k];
      count=0;
      for (int i=0; i<nolines; i++) {
         pos=ifil.tellg();
         getline(ifil,line);
         if (line.length()==0) {getline(ifil,line); pos++;}
         for (int j=0; j<5; j++) {
            if (count<npr) {
               if ((line[12]=='D')||(line[12]=='d')) {
                  line[12]='e';
               }
               moc[(k*npr)+count]=(solreal)atof((line.substr(0,16)).c_str());
               count++;
               line.erase(0,16);
            }
         }
      }
   }
}
開發者ID:jmsolano,項目名稱:denstoolkit,代碼行數:39,代碼來源:iofuncts-wfn.cpp

示例6: String2Dbl

double String2Dbl (string& iStlString)
{
    return atof (iStlString.c_str());
}
開發者ID:agapow,項目名稱:mesa-revenant,代碼行數:4,代碼來源:StringUtils.cpp

示例7: processPrimitivesWFN

/* ********************************************************************************************* */
void processPrimitivesWFN(ifstream &ifil,const int npr,int* &pricen,int* &primty,solreal* &prexp)
{
   alloc1DIntArray("pricen",npr,pricen);
   alloc1DIntArray("primty",npr,primty);
   alloc1DRealArray("prexp",npr,prexp);
   int count=0;
   int pos;
   /* Getting the primitive centers */
   pos=ifil.tellg();
   ifil.seekg(pos+20);
   for (int i=0; i<npr; i++) {
      ifil >> pricen[i];
      pricen[i]--;
      count++;
      if (count==20) {
         pos=ifil.tellg();
         ifil.seekg(pos+20);
         count=0;
      }
      //cout << pricen[i] << " ";
   }
   if ((npr%20)==0) {
      pos=ifil.tellg();
      ifil.seekg(pos-20);
   }
   /* Getting the primitive types */
   pos=ifil.tellg();
   ifil.seekg(pos+20);
   count=0;
   for (int i=0; i<npr; i++) {
      ifil >> primty[i];
      primty[i]--;
      count++;
      if (count==20) {
         pos=ifil.tellg();
         ifil.seekg(pos+20);
         count=0;
      }
      //cout << primty[i] << " ";
   }
   if ((npr%20)==0) {
      pos=ifil.tellg();
      ifil.seekg(pos-20);
   }
   /* Getting the primitive exponents */
   string line;
   int nolines;
   nolines=floor(npr/5);
   if ((npr%5)>0) {nolines++;}
   count=0;
   for (int i=0; i<nolines; i++) {
      pos=ifil.tellg();
      getline(ifil,line); 
      if (line.length()==0) {getline(ifil,line); pos++;}
      line.erase(0,10);
      for (int j=0; j<5; j++) {
         if (count<npr) {
            if ((line[10]=='D')||(line[10]=='d')) {
               line[10]='e';
            }
            prexp[count]=(solreal)atof((line.substr(0,14)).c_str());
            count++;
            line.erase(0,14);
         }
      }
   }
}
開發者ID:jmsolano,項目名稱:denstoolkit,代碼行數:68,代碼來源:iofuncts-wfn.cpp

示例8: asDouble

double Arguments::asDouble(int index) const {
    return atof(argList[index].c_str());
}
開發者ID:scaryghost,項目名稱:CppUtilities,代碼行數:3,代碼來源:Arguments.cpp


注:本文中的std::atof方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。