Click here to Skip to main content
15,914,070 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: ON_WM_KILLFOCUS Pin
digwizfox13-Jan-05 6:33
digwizfox13-Jan-05 6:33 
GeneralDynamic Views Pin
Anonymous12-Jan-05 15:12
Anonymous12-Jan-05 15:12 
GeneralRe: Dynamic Views Pin
Yulianto.12-Jan-05 15:31
Yulianto.12-Jan-05 15:31 
GeneralMSVC 2003 GUI Help Pin
c++code10112-Jan-05 14:31
c++code10112-Jan-05 14:31 
GeneralSending output to a printer Pin
BRIMID12-Jan-05 13:29
BRIMID12-Jan-05 13:29 
GeneralMFC socket programing problem Pin
shaihnc12-Jan-05 12:39
shaihnc12-Jan-05 12:39 
GeneralRe: MFC socket programing problem Pin
shaihnc13-Jan-05 5:32
shaihnc13-Jan-05 5:32 
GeneralSpeed of operators Pin
Malcolm Smart12-Jan-05 11:57
Malcolm Smart12-Jan-05 11:57 
This is not homework - honest - wished it was at 34Sigh | :sigh: !

I am just flicking through some code suggestions I found on the web and one was about pure performance which I haven't really looked into much, I am more of a GUI person, always waiting for the user! Anyway, cut to the chase....

If speed alone is purely the issue, which would be faster :-

int A_Return_n_if_n_isIsLessThan2(unsigned int n)
{
if (n < 2)
   return n;
else 
   return -1;
}

int B_Return_n_if_n_isIsLessThan2(unsigned int n)
{
if (n ==0 || n == 1)
   return n;
else 
   return -1;
}

int C_Return_n_if_n_isIsLessThan2(unsigned int n)
{
return (n < 2 ? n : -1);
}

int D_Return_n_if_n_isIsLessThan2(unsigned int n)
{
return ((n == 0 || n == 1) ? n : -1);
}


I would have said 'C' but things aren't always that straight forward, especially when people start talking about 'atomic' operations - not too sure about those!!

Also, what would be the speed of these in big O notation? And how do you know that, or is that a far bigger subject?

Regards

Angel


*********************************************
The sooner you fall behind, the longer you have to catch up.
GeneralRe: Speed of operators Pin
Rick York12-Jan-05 12:18
mveRick York12-Jan-05 12:18 
GeneralRe: Speed of operators Pin
Mike Dimmick12-Jan-05 12:19
Mike Dimmick12-Jan-05 12:19 
GeneralRe: Speed of operators Pin
Mike Dimmick12-Jan-05 12:59
Mike Dimmick12-Jan-05 12:59 
GeneralRe: Speed of operators Pin
Ryan Binns12-Jan-05 16:58
Ryan Binns12-Jan-05 16:58 
GeneralOnSize Function : Positioning Static Controls Pin
tnguyen44412-Jan-05 11:50
tnguyen44412-Jan-05 11:50 
GeneralRe: OnSize Function : Positioning Static Controls Pin
User 1278212-Jan-05 16:13
User 1278212-Jan-05 16:13 
GeneralRe: OnSize Function : Positioning Static Controls Pin
Ryan Binns12-Jan-05 17:01
Ryan Binns12-Jan-05 17:01 
GeneralRe: OnSize Function : Positioning Static Controls Pin
tnguyen44413-Jan-05 6:10
tnguyen44413-Jan-05 6:10 
GeneralForms Problem (new to Win32 programming) Pin
LighthouseJ12-Jan-05 11:30
LighthouseJ12-Jan-05 11:30 
GeneralChecking Namedpipe Access Pin
humps12-Jan-05 10:43
humps12-Jan-05 10:43 
GeneralSetActivePage in property page Pin
DanYELL12-Jan-05 9:58
DanYELL12-Jan-05 9:58 
GeneralRe: SetActivePage in property page Pin
Michael Dunn12-Jan-05 10:23
sitebuilderMichael Dunn12-Jan-05 10:23 
GeneralRe: SetActivePage in property page Pin
DanYELL12-Jan-05 12:28
DanYELL12-Jan-05 12:28 
GeneralRe: SetActivePage in property page Pin
Michael Dunn12-Jan-05 14:50
sitebuilderMichael Dunn12-Jan-05 14:50 
Generalbrowsing DLL resource files through CFileDialog Pin
(Steven Hicks)n+112-Jan-05 8:13
(Steven Hicks)n+112-Jan-05 8:13 
GeneralRe: browsing DLL resource files through CFileDialog Pin
Neville Franks12-Jan-05 8:57
Neville Franks12-Jan-05 8:57 
GeneralRe: browsing DLL resource files through CFileDialog Pin
Ryan Binns12-Jan-05 17:06
Ryan Binns12-Jan-05 17: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.