Click here to Skip to main content
14,691,587 members
Home » Discussions » C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: (C) Robust code Should an unsigned int array index be tested for "< 0" Pin
David Crow11-Jan-19 8:33
MemberDavid Crow11-Jan-19 8:33 
GeneralRe: (C) Robust code Should an unsigned int array index be tested for "< 0" Pin
Joe Woodbury11-Jan-19 12:54
professionalJoe Woodbury11-Jan-19 12:54 
GeneralRe: (C) Robust code Should an unsigned int array index be tested for "< 0" Pin
HS_C_Student11-Jan-19 13:18
MemberHS_C_Student11-Jan-19 13:18 
GeneralRe: (C) Robust code Should an unsigned int array index be tested for "< 0" Pin
leon de boer12-Jan-19 4:36
Memberleon de boer12-Jan-19 4:36 
GeneralRe: (C) Robust code Should an unsigned int array index be tested for "< 0" Pin
HS_C_Student12-Jan-19 5:59
MemberHS_C_Student12-Jan-19 5:59 
AnswerRe: (C) Robust code Should an unsigned int array index be tested for "< 0" Pin
Bram van Kampen12-Jan-19 15:01
MemberBram van Kampen12-Jan-19 15:01 
GeneralRe: (C) Robust code Should an unsigned int array index be tested for "< 0" Pin
HS_C_Student12-Jan-19 17:50
MemberHS_C_Student12-Jan-19 17:50 
GeneralRe: (C) Robust code Should an unsigned int array index be tested for "< 0" Pin
Richard MacCutchan12-Jan-19 23:51
mveRichard MacCutchan12-Jan-19 23:51 
Member 14088880 wrote:
//This is the thing that caught me off guard. "uint_neg_1 < 0" does not evaluate to true.
And that is correct. An unsigned number can only have positive values in the range 0 to infinity. The main point here is that you must follow the rules of mathematics and logic. If you declare a numeric variable as unsigned then that is how it will be treated, and it will never be considered to have a negative value (even if it does have the sign bit set). The compiler will add code to manipulate the value in such a way that any 'negativeness' is always ignored.
GeneralRe: (C) Robust code Should an unsigned int array index be tested for "< 0" Pin
HS_C_Student13-Jan-19 8:10
MemberHS_C_Student13-Jan-19 8:10 
GeneralRe: (C) Robust code Should an unsigned int array index be tested for "< 0" Pin
Richard MacCutchan13-Jan-19 23:12
mveRichard MacCutchan13-Jan-19 23:12 
AnswerDemonstrating the relevant case and potential best practice Pin
HS_C_Student13-Jan-19 7:46
MemberHS_C_Student13-Jan-19 7:46 
GeneralRe: Demonstrating the relevant case and potential best practice Pin
Richard MacCutchan13-Jan-19 23:15
mveRichard MacCutchan13-Jan-19 23:15 
AnswerRe: (C) Robust code Should an unsigned int array index be tested for "< 0" Pin
Stefan_Lang17-Jan-19 0:13
mveStefan_Lang17-Jan-19 0:13 
GeneralRe: (C) Robust code Should an unsigned int array index be tested for "< 0" Pin
HS_C_Student17-Jan-19 14:05
MemberHS_C_Student17-Jan-19 14:05 
Questionacademic question - usage of class variable Pin
Vaclav_10-Jan-19 6:20
MemberVaclav_10-Jan-19 6:20 
AnswerRe: academic question - usage of class variable Pin
Richard MacCutchan10-Jan-19 7:27
mveRichard MacCutchan10-Jan-19 7:27 
AnswerRe: academic question - usage of class variable Pin
CPallini10-Jan-19 22:28
mveCPallini10-Jan-19 22:28 
GeneralRe: academic question - usage of class variable Pin
Vaclav_11-Jan-19 4:25
MemberVaclav_11-Jan-19 4:25 
GeneralRe: academic question - usage of class variable Pin
CPallini11-Jan-19 6:21
mveCPallini11-Jan-19 6:21 
GeneralRe: academic question - usage of class variable Pin
David Crow11-Jan-19 6:44
MemberDavid Crow11-Jan-19 6:44 
AnswerRe: academic question - usage of class variable Pin
Stefan_Lang16-Jan-19 23:26
mveStefan_Lang16-Jan-19 23:26 
QuestionChanging CMainFrame Minimize ICON Pin
ForNow9-Jan-19 15:02
MemberForNow9-Jan-19 15:02 
QuestionRe: Changing CMainFrame Minimize ICON Pin
David Crow10-Jan-19 5:07
MemberDavid Crow10-Jan-19 5:07 
AnswerRe: Changing CMainFrame Minimize ICON Pin
ForNow10-Jan-19 5:39
MemberForNow10-Jan-19 5:39 
GeneralRe: Changing CMainFrame Minimize ICON Pin
David Crow10-Jan-19 5:42
MemberDavid Crow10-Jan-19 5:42 

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.