Click here to Skip to main content
15,891,702 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: some help for how shutdown computer remotely Pin
Christian Graus2-Nov-04 11:50
protectorChristian Graus2-Nov-04 11:50 
Generallogging off windows 2000 in VC++ Pin
jet91532-Nov-04 9:49
jet91532-Nov-04 9:49 
GeneralRe: logging off windows 2000 in VC++ Pin
David Crow2-Nov-04 10:39
David Crow2-Nov-04 10:39 
GeneralRe: logging off windows 2000 in VC++ Pin
Ryan Binns2-Nov-04 16:58
Ryan Binns2-Nov-04 16:58 
Generala dynamic-link library for 3D GameStudio Pin
BeyelerStudios2-Nov-04 9:47
BeyelerStudios2-Nov-04 9:47 
GeneralAbout scrollbars Pin
n_a12-Nov-04 8:43
n_a12-Nov-04 8:43 
GeneralRe: About scrollbars Pin
n_a12-Nov-04 23:14
n_a12-Nov-04 23:14 
GeneralHelp me speed this up! Pin
Nitron2-Nov-04 8:36
Nitron2-Nov-04 8:36 
Ok, so I have this formatting function because I need 2 digits after the exponent and VS7.1 puts out 3 by default. So anyway, the code is pretty verbose and slow. Anyone care to take the blinders off my eyes and optimize this?

std::string CDataFile::mf_FormatNumber(const int& iVariable, const int& iSample, const bool& bIsDAT_Format)
{
	try
	{
		char buffer[200]       = {0};
		std::string numstring  = "";
		std::string buffstring = "";
		std::string result     = "";

		if(bIsDAT_Format)
		{
			result = (m_v2dData.at(iVariable).at(iSample) >= 0.0) ? std::string(" ") : std::string("");
			sprintf( buffer,"%.5E", m_v2dData.at(iVariable).at(iSample));
		}
		else
		{
			result = (m_v2dData.at(iVariable).at(iSample) >= 0.0) ? "  " : " ";
			sprintf( buffer,"%.17E", m_v2dData.at(iVariable).at(iSample));
		}

		numstring  = buffer;

		if(numstring.length()-numstring.find_last_of("E") == 5)
		{
			buffstring = numstring;

			if(bIsDAT_Format)
				numstring.resize((m_v2dData.at(iVariable).at(iSample) >= 0.0) ? 9 : 10);
			else
				numstring.resize((m_v2dData.at(iVariable).at(iSample) >= 0.0) ? 21 : 22);

			numstring += buffstring[buffstring.find_last_of("E")+3];
			numstring += buffstring[buffstring.find_last_of("E")+4];
		}

		result += numstring;
		return result;
	}

	catch(...)
	{
		std::string szerr = "";
		char errbuff[1024] = {0};
		sprintf(errbuff,"ERROR formatting Var: %d Sample %d! \nDetails: %s", iVariable, iSample,m_szError.c_str());
		szerr = errbuff;
		return szerr;
	}
}


~Nitron.
ññòòïðïðB A
start

GeneralRe: Help me speed this up! Pin
Joaquín M López Muñoz2-Nov-04 9:13
Joaquín M López Muñoz2-Nov-04 9:13 
GeneralRe: Help me speed this up! Pin
Nitron2-Nov-04 9:21
Nitron2-Nov-04 9:21 
QuestionHow to Declare program, Menu and Dialog Pin
Dody_DK2-Nov-04 8:32
Dody_DK2-Nov-04 8:32 
GeneralRe: func to create 2-d array in C Pin
Joaquín M López Muñoz2-Nov-04 8:26
Joaquín M López Muñoz2-Nov-04 8:26 
GeneralRe: func to create 2-d array in C Pin
Budric B.2-Nov-04 8:34
Budric B.2-Nov-04 8:34 
GeneralRe: func to create 2-d array in C Pin
act_x2-Nov-04 8:40
act_x2-Nov-04 8:40 
Generalfunc to create 2-d array in C Pin
act_x2-Nov-04 8:13
act_x2-Nov-04 8:13 
General"cout" and "cin" won't work Pin
Verolix2-Nov-04 7:25
Verolix2-Nov-04 7:25 
GeneralRe: "cout" and "cin" won't work Pin
Joaquín M López Muñoz2-Nov-04 8:19
Joaquín M López Muñoz2-Nov-04 8:19 
GeneralRe: "cout" and "cin" won't work Pin
Verolix2-Nov-04 9:59
Verolix2-Nov-04 9:59 
GeneralRe: "cout" and "cin" won't work Pin
Joaquín M López Muñoz2-Nov-04 10:07
Joaquín M López Muñoz2-Nov-04 10:07 
GeneralRe: "cout" and "cin" won't work Pin
Verolix2-Nov-04 10:15
Verolix2-Nov-04 10:15 
GeneralMoving Horz ScrollBar Pin
manosza2-Nov-04 6:52
manosza2-Nov-04 6:52 
Generalpreferences in registry Pin
ehh2-Nov-04 6:37
ehh2-Nov-04 6:37 
GeneralRe: preferences in registry Pin
BlackDice2-Nov-04 6:46
BlackDice2-Nov-04 6:46 
GeneralRe: preferences in registry Pin
David Crow2-Nov-04 6:56
David Crow2-Nov-04 6:56 
GeneralRe: preferences in registry Pin
Blake Miller2-Nov-04 7:46
Blake Miller2-Nov-04 7:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.