Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
kira25727y@fuck2code whatever, but please we genuinely count from 1. So it would be better if array's counting start from 1.
-
Array indexes are not a position, they are an *offset*. Once you get your head around that difference it all makes sense.
-
kira25727y@AlpineLinnix why? Generally, suppose if you want to count 10 numbers then how will you count 1 to 10 or 0 to 9?
-
taglia5717y@Mayank007 ARE YOU SERIOUS?
Natural numbers start from 0.
Positive integers start from 1.
@thesagya look at the comment of @Zaphod65.
Have you ever worked with C and pointers? If not, give it a try, you'll immediately understand why arrays start at 0 and not with 1. -
@fuck2code A natural number is a number that occurs commonly and obviously in nature. As such, it is a whole, non-negative number. The set of natural numbers, denoted N, can be defined in either of two ways:
N = (1, 2, 3, 4, ...}
N = {0, 1, 2, 3, ...}
You are right but i am not wrong :)
// check the brackets of number notation too. -
@fuck2code I don't really see difficulty of implementing same thing if you start from 1. He just assumed it would start from 0 and didn't even gave a chance to 1. All of his issues came from his preconception as a software developer that numbers start from 0. I mean, why not go from -74? Seems just as natural to me: "Please give me second item from this array - array[-73]". Yep, this is just as ridiculous as array[1] for second item. Second = 1, lel.
-
@taglia Numbers starting from zero are whole numbers. Numbers starting from one are natural numbers(the ones we use for counting).
-
@fuck2code there might be difference between standards i guess but what i was taught in school is this.
-
@fuck2code it's just a naming for positive set of integers and i guess you know how flexible naming convention can be.
-
Think about it this way: the index is a memory offset
arr[4] == *(arr + 4)
arr[1] != *(arr) -
taglia5717y@Mayank007 TL;DR: 0 is part of â„•.
From wikipedia:
"Some definitions, including the standard ISO 80000-2,[1] begin the natural numbers with 0, corresponding to the non-negative integers 0, 1, 2, 3, …, whereas others start with 1, corresponding to the positive integers 1, 2, 3, ….[2][3][4][5] Texts that exclude zero from the natural numbers sometimes refer to the natural numbers together with zero as the whole numbers, but in other writings, that term is used instead for the integers (including negative integers).".
Standard ISO 80000-2, which is the evolution of 31-11 (https://en.wikipedia.org/wiki/...), state:
"â„• -> the set of natural numbers; the set of positive integers and zero
â„• = {0, 1, 2, 3, ...}
Exclusion of zero is denoted by an asterisk:
â„•* = {1, 2, 3, ...}" -
taglia5717y@thesagya at the beginning it was weird for everyone, but then, when you end up using memory addresses, it all makes sense :)
Related Rants
Fuck you arrays.
Why the fuck you want to start with '0'? Ohh I forgot If you will start with '1' then you can't fuck with us. Let it be you f***
rant
arrays starts at 0