Click here to Skip to main content
14,328,676 members

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
GeneralRe: Nested if-else statements... Pin
dusty_dex24-Apr-13 3:43
memberdusty_dex24-Apr-13 3:43 
GeneralRe: Nested if-else statements... Pin
NAANsoft24-Apr-13 2:44
memberNAANsoft24-Apr-13 2:44 
GeneralRe: Nested if-else statements... Pin
Lee Chetwynd24-Apr-13 5:07
memberLee Chetwynd24-Apr-13 5:07 
GeneralRe: Nested if-else statements... Pin
RafagaX24-Apr-13 5:41
professionalRafagaX24-Apr-13 5:41 
GeneralRe: Nested if-else statements... Pin
tumbledDown2earth29-Apr-13 20:32
membertumbledDown2earth29-Apr-13 20:32 
GeneralRe: Nested if-else statements... Pin
fulloflove2-May-13 17:19
memberfulloflove2-May-13 17:19 
GeneralRe: Nested if-else statements... Pin
Filipe Moreira de Oliveira18-May-13 8:00
memberFilipe Moreira de Oliveira18-May-13 8:00 
Answer[Solved] Why Do Computer Counts from Zero. Pin
kburman622-Apr-13 6:47
professionalkburman622-Apr-13 6:47 
Link to the article
For More detail explanation(PDF)

Counting arrays from 0 simplifies the computation of the memory address of each element.

If an array is stored at a given position in memory (it’s called the address) the position of each element can be computed as
element(n) = address + n * size_of_the_element
//If you consider the first element the first, the computation becomes

element(n) = address + (n-1) * size_of_the_element
//Not a huge difference but it adds an unnecessary subtraction for each access.


modified 22-Apr-13 13:45pm.

GeneralRe: [Solved] Why Do Computer Counts from Zero. Pin
Marco Bertschi22-Apr-13 7:18
protectorMarco Bertschi22-Apr-13 7:18 
GeneralRe: [Solved] Why Do Computer Counts from Zero. Pin
Thomas Daniels22-Apr-13 7:25
mveThomas Daniels22-Apr-13 7:25 
GeneralRe: [Solved] Why Do Computer Counts from Zero. Pin
lw@zi 22-Apr-13 7:36
professional lw@zi 22-Apr-13 7:36 
GeneralRe: [Solved] Why Do Computer Counts from Zero. Pin
kburman622-Apr-13 7:44
professionalkburman622-Apr-13 7:44 
GeneralRe: [Solved] Why Do Computer Counts from Zero. Pin
Marco Bertschi22-Apr-13 7:45
protectorMarco Bertschi22-Apr-13 7:45 
GeneralRe: [Solved] Why Do Computer Counts from Zero. Pin
kburman622-Apr-13 7:36
professionalkburman622-Apr-13 7:36 
GeneralRe: [Solved] Why Do Computer Counts from Zero. Pin
Marco Bertschi22-Apr-13 7:46
protectorMarco Bertschi22-Apr-13 7:46 
GeneralRe: [Solved] Why Do Computer Counts from Zero. Pin
kburman622-Apr-13 7:52
professionalkburman622-Apr-13 7:52 
GeneralRe: [Solved] Why Do Computer Counts from Zero. Pin
OriginalGriff22-Apr-13 8:43
protectorOriginalGriff22-Apr-13 8:43 
GeneralRe: [Solved] Why Do Computer Counts from Zero. Pin
Erik Rude24-Apr-13 3:55
memberErik Rude24-Apr-13 3:55 
GeneralRe: [Solved] Why Do Computer Counts from Zero. Pin
PIEBALDconsult24-Apr-13 4:08
protectorPIEBALDconsult24-Apr-13 4:08 
GeneralRe: [Solved] Why Do Computer Counts from Zero. Pin
Clifford Nelson22-Apr-13 9:09
mvaClifford Nelson22-Apr-13 9:09 
GeneralRe: [Solved] Why Do Computer Counts from Zero. Pin
PIEBALDconsult24-Apr-13 4:06
protectorPIEBALDconsult24-Apr-13 4:06 
GeneralRe: [Solved] Why Do Computer Counts from Zero. Pin
Clifford Nelson24-Apr-13 10:14
mvaClifford Nelson24-Apr-13 10:14 
GeneralRe: [Solved] Why Do Computer Counts from Zero. Pin
PIEBALDconsult24-Apr-13 11:58
protectorPIEBALDconsult24-Apr-13 11:58 
GeneralRe: [Solved] Why Do Computer Counts from Zero. Pin
Clifford Nelson24-Apr-13 12:48
mvaClifford Nelson24-Apr-13 12:48 
GeneralRe: [Solved] Why Do Computer Counts from Zero. Pin
PIEBALDconsult24-Apr-13 16:00
protectorPIEBALDconsult24-Apr-13 16:00 

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.