Click here to Skip to main content
15,921,577 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Retrieve the length of an int Pin
David Crow3-Aug-07 4:22
David Crow3-Aug-07 4:22 
GeneralRe: Retrieve the length of an int Pin
LordMarv3-Aug-07 4:34
LordMarv3-Aug-07 4:34 
AnswerRe: Retrieve the length of an int Pin
David Crow3-Aug-07 4:12
David Crow3-Aug-07 4:12 
GeneralRe: Retrieve the length of an int Pin
Perspx3-Aug-07 4:15
Perspx3-Aug-07 4:15 
GeneralRe: Retrieve the length of an int Pin
David Crow3-Aug-07 4:23
David Crow3-Aug-07 4:23 
GeneralRe: Retrieve the length of an int Pin
Perspx3-Aug-07 4:26
Perspx3-Aug-07 4:26 
GeneralRe: Retrieve the length of an int Pin
CPallini3-Aug-07 4:27
mveCPallini3-Aug-07 4:27 
GeneralRe: Retrieve the length of an int Pin
David Crow3-Aug-07 5:01
David Crow3-Aug-07 5:01 
Perspx wrote:
I bet that the reason that most Microsoft programs are slow and clunky...


I highly doubt that. Reserving 1 byte or 20 bytes from the stack will make no noticeable difference in your code's execution time, but using the log10() function and asking the memory manager for countless small amounts of memory will.

Consider the following:

for (int x = 0; x < nFileCount; x++)
{
    int nLength = (int) (log10(dwFileSize) + 1.0); 
    char *s = new char[18 + nLength];
    sprintf(s, "File Size: %lu bytes", dwFileSize);
    delete [] s;
}
compared to:

char s[28];
for (int x = 0; x < nFileCount; x++)
{
    sprintf(s, "File Size: %lu bytes", dwFileSize);
}





"A good athlete is the result of a good and worthy opponent." - David Crow

"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne


GeneralRe: Retrieve the length of an int Pin
CPallini3-Aug-07 4:26
mveCPallini3-Aug-07 4:26 
GeneralRe: Retrieve the length of an int Pin
Perspx3-Aug-07 4:28
Perspx3-Aug-07 4:28 
AnswerRe: Retrieve the length of an int [modified] Pin
m.dietz3-Aug-07 4:16
m.dietz3-Aug-07 4:16 
GeneralRe: Retrieve the length of an int Pin
CPallini3-Aug-07 4:52
mveCPallini3-Aug-07 4:52 
AnswerRe: Retrieve the length of an int Pin
CPallini3-Aug-07 4:25
mveCPallini3-Aug-07 4:25 
GeneralRe: Retrieve the length of an int Pin
Perspx3-Aug-07 4:28
Perspx3-Aug-07 4:28 
GeneralRe: Retrieve the length of an int Pin
CPallini3-Aug-07 4:42
mveCPallini3-Aug-07 4:42 
GeneralRe: Retrieve the length of an int Pin
Perspx3-Aug-07 4:46
Perspx3-Aug-07 4:46 
GeneralRe: Retrieve the length of an int Pin
dburns3-Aug-07 5:00
dburns3-Aug-07 5:00 
GeneralRe: Retrieve the length of an int Pin
Perspx3-Aug-07 5:02
Perspx3-Aug-07 5:02 
GeneralRe: Retrieve the length of an int Pin
Rage3-Aug-07 4:47
professionalRage3-Aug-07 4:47 
QuestionHack a modal dialog to not close? Pin
Jim @ JCT3-Aug-07 3:59
Jim @ JCT3-Aug-07 3:59 
AnswerRe: Hack a modal dialog to not close? Pin
Rage3-Aug-07 4:11
professionalRage3-Aug-07 4:11 
GeneralRe: Hack a modal dialog to not close? Pin
Jim @ JCT3-Aug-07 5:06
Jim @ JCT3-Aug-07 5:06 
QuestionHow recieve time from system time Pin
myshketer3-Aug-07 3:23
myshketer3-Aug-07 3:23 
QuestionRe: How recieve time from system time Pin
David Crow3-Aug-07 3:37
David Crow3-Aug-07 3:37 
AnswerRe: How recieve time from system time Pin
myshketer3-Aug-07 4:06
myshketer3-Aug-07 4:06 

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.