5 ms·
what does 1-based mean?
by hwers 5y ago
what does 1-based mean?
- calebegg 5y agoThe first element of the array is A[1], rather than A[0] like it would be in nearly all programming languages.
- dredmorbius 5y agoThere is of course the compromise position of 0.5.
- tom_ 5y agoI prefer 9. It makes no less sense than 1, but it is conveniently much closer to the + and - keys.
- notriddle 5y agoMy 0 key is twice as big as the rest of the digits.
- DougBTX 5y agohttps://www.realtimerendering.com/blog/the-center-of-the-pixel-is-0-50-5/ https://www.realtimerendering.com/blog/the-center-of-the-pix...
- Joker_vD 5y agoHuh. I thought it was obvious: e.g., the top-left corner of the screen is (0, 0), the bottom-right corner is (640, 480), and pixels are 1x1 — we take the coordinate of their top-left corner to be their coordinate, so the top-left pixel has coordinates (0, 0), and the bottom-right one has (639, 479), and obviously the coordinates of their centres are (0.5, 0.5) and (639.5, 479.5). But apparently some people treated pixels as geometrical points without size?
- foxfluff 5y agoIt's normal in signal processing to treat samples (whether audio or image) as points. A lot of things stop making sense if you replace them with line segments and rectangles.
- goohle 5y agoWhich is rounded down to 0 or up to 1 at random.
- Scarblac 5y agoWhy compromise? Just have a helpful variable like Perl's $[ to set the first element index.
- goatlover 5y agoNearly all meaning the non-scientific computing ones, and particularly the ones with syntax inspired by C. Fortran, APL, Matlab, Wolfram, Mathematica, R, Julia, Cobol, Smalltalk and Lua are all 1-based, at least by default.
- Scarblac 5y agoOr maybe not so much inspired by C, but inspired by similar arguments as Dijkstra makes in his "Why numbering should start at zero": https://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/EWD831.html https://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/E....
- red_trumpet 5y agoIt's entries are A[1], A[2],...,A[n] instead of A[0], A[1],...,A[n-1].
- jimmyed 5y agoIt means you probably shouldn't be on Hackernews
- castis 5y agoIt means they should definitely be on HN where they're very likely to learn new things.
- ZeroCool2u 5y agoWelcoming open, thoughtful discussion and having people much smarter and with more experience than myself available to answer questions in which I'm not an expert is one of the main reasons I frequent HN.
- findalex 5y ago> too young to know FORTRAN. If you don't know, you don't know.
- fullstop 5y agoThe array indexes start at 1, not 0.
- deleted 5y ago[deleted]
- deleted 5y ago[deleted]