+ 5

Why are we starting 0 in array?

16th Sep 2018, 1:28 AM
Rohit Kumar
Rohit Kumar - avatar
8 Respuestas
+ 4
🌴Vincent Berger🌴 I doubt that anything is converted to hexadecimals in the process because a CPU has no idea what hexadecimals are and what to do with them. Basically, hexadecimals are a more compact way to write binaries. They are made for humans, not for computers. For humans, 0xFACE is easier to interpret than 0b1111101011001110, and a memory address with 10 hexadecimals is easier to handle than its binary representation with 40 digits. That's the only reason hexadecimals are used. Also, the 0/1 thing is only the most common way to describe the two states of a binary system. You could use off/on, A/B, -/+, low/high, yin/yang etc. as well to describe the same. I don't think that the binary "0" has anything to do with indices of arrays or lists
16th Sep 2018, 6:00 AM
Anna
Anna - avatar
+ 9
Because 0 is also a number and only programmers appreciated the value of 0. 😅 Also in counting, 0 is always mentioned.
16th Sep 2018, 3:16 AM
Email Not Activated
+ 4
thanku for all
11th Oct 2018, 2:32 PM
Rohit Kumar
Rohit Kumar - avatar
+ 2
Morpheus, Excuse me? What u mean with that?
16th Sep 2018, 2:47 AM
🌴Vincent Berger🌴
🌴Vincent Berger🌴 - avatar
+ 2
Morpheus, I learned that a few years ago. If my answer is incorrect, explanation would be appericiated👍
16th Sep 2018, 2:59 AM
🌴Vincent Berger🌴
🌴Vincent Berger🌴 - avatar
+ 2
Simplest answer : Counting starts from 0 in programming instead of 1. That is why when you create an int array of size 5 but you cannot access its fifth element like this arr[5] that would give an IndexOutOfBound error. This is because the very first index of array we access is like arr[0] so to access the last index we would use arr[4]
16th Sep 2018, 4:30 AM
blACk sh4d0w
blACk sh4d0w - avatar
- 2
hf
16th Sep 2018, 5:07 PM
ahmad