Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
seiken
Feb 7, 2005

hah ha ha

coffeetable posted:

9,007,199,254,740,993

9,007,199,254,740,992 should be enough for anybody

Adbot
ADBOT LOVES YOU

Symbolic Butt
Mar 22, 2009

(_!_)
Buglord

seiken posted:

edit: see also http://en.wikipedia.org/wiki/Modulo_operation (the top graph is what most languages use, the bottom graph is obviously the best)

btw I don't get why this is a separate page from "modular arithmetic", this looks like a really arbitrary wikipedia division heh look at this pun

seiken
Feb 7, 2005

hah ha ha

Symbolic Butt posted:

btw I don't get why this is a separate page from "modular arithmetic", this looks like a really arbitrary wikipedia division heh look at this pun

I know right, I usually want to link to this image when this comes up and it takes me like four google searches to find it every time

the talent deficit
Dec 20, 2003

self-deprecation is a very british trait, and problems can arise when the british attempt to do so with a foreign culture





all you need to know to realize computer science is the worst science is that people get literally angry when someone suggests that maybe zero based indexing - divorced from the context of pointer offsets - maybe doesn't make any sense

prefect
Sep 11, 2001

No one, Woodhouse.
No one.




Dead Man’s Band

the talent deficit posted:

all you need to know to realize computer science is the worst science is that people get literally angry when someone suggests that maybe zero based indexing - divorced from the context of pointer offsets - maybe doesn't make any sense

the even-more-dismal science?

Malcolm XML
Aug 8, 2009

I always knew it would end like this.

the talent deficit posted:

all you need to know to realize computer science is the worst science is that people get literally angry when someone suggests that maybe zero based indexing - divorced from the context of pointer offsets - maybe doesn't make any sense

seiken
Feb 7, 2005

hah ha ha

the talent deficit posted:

all you need to know to realize computer science is the worst science is that people get literally angry when someone suggests that maybe zero based indexing - divorced from the context of pointer offsets - maybe doesn't make any sense

grats on being wilfully ignorant I guess

MononcQc
May 29, 2007

0-indexing works well with offsets, 1-indexing works well with positions. Both can even coexist fine.

the talent deficit
Dec 20, 2003

self-deprecation is a very british trait, and problems can arise when the british attempt to do so with a foreign culture





MononcQc posted:

0-indexing works well with offsets, 1-indexing works well with positions. Both can even coexist fine.

offsets are meaningless without a position to offset from. if you're using offsets you have an implied, unstated position. why bother with the indirection?

MononcQc
May 29, 2007

That's why they give the platinum medal for the 0th runner to finish the race

my homie dhall
Dec 9, 2010

honey, oh please, it's just a machine
can't wait for the brilliant discussion that's about to go down

MononcQc
May 29, 2007

Can probably look back a hundred pages or so and copy/paste it in advance.

fart simpson
Jul 2, 2005

DEATH TO AMERICA
:xickos:

last time i remember somebody linking to a dijkstra paper about it

MononcQc
May 29, 2007

MeramJert posted:

last time i remember somebody linking to a dijkstra paper about it

https://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/EWD831.html

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

some next-level ordinal chat itt

shrughes
Oct 11, 2008

(call/cc call/cc)

MononcQc posted:

0-indexing works well with offsets, 1-indexing works well with positions. Both can even coexist fine.

Do you like, actually program? Because this is retarded.

jony neuemonic
Nov 13, 2009

shrughes posted:

Do you like, actually program? Because this is retarded.

:suspense:

brap
Aug 23, 2004

Grimey Drawer
primary keys in sql start at 1 and i don't see anyone weeping about that (only about sql in general)

tef
May 30, 2004

-> some l-system crap ->
i used to get butt hurt over 0 vs 1 based indexing, mostly because i'd learned offsets, and did a lot more of < n than < n+1. but the nicest thing i've seen about 0 based indexing, is python's negative indexes.

for ex: in python strings, where foo[0] .. foo[n-1] and foo[-n] .. foo[-1] are the same ranges. i really like the fact that python's are continuous, i.e 0 is the first element, so -1 is the last element. for this to work with 1 based indexing, the ranges would have to be foo[-len+1] .. foo[0]. there's a tiny catch though: the negative indexes are sorta 1-indexed, but the positive ones are all 0-indexes.

you can do a similar trick for 1 indexed strings, so foo[1]..foo[len] is foo[-n+1] ... foo[0]. but like before, the negative numbers have a different 'offset'. i reckon it's less weird to have 0 as the start of a list than to have 0 as the end of the list — it works nicer with modulo too, so -1 in a 4 element list is -1 % 4 = 3

i think this is a fairly similar argument that many have taken before, but i've been caring less and less about it: when i'm doing x++ and a x<len somewhere, i usually have counting errors. when i play around with for x in ..., on the other hand, i don't as much. zip and co are pretty awesome for list shenanigans. if i have to care about if it is 0 indexed or 1 indexed i'm probably doing some horrible string or list mangling in a language that never discovered how to use iterators well.

but i still cared a bit. what destroyed my care about 0 or 1 indexed lists was teaching some kids about coding, and had to explain 0 based indexing. i explained it as an offset from the start, teaching them to mentally subtract 1 from the index. it felt like some sort of character building exercise, wherein i proclaimed "trust me, it's useful when you're older". as mathematically pleasing as it feels, i felt like a dad.

as much as 1 based indexing feels weird, someone pointed out to me that you could do foo[1] .. foo[len], and foo[-len] .. foo[len]. foo[0] would always be an error, both are 1 indexed from head and tail of list. there's also the nice foo[-n] == reversed(foo)[+n] property going for it too. it has similar mathematical neatness, negative indexing, but it's discontinuous. c'est la vie.


if i was writing a language for kids i'd probably use that instead of 0 based indexing.

MononcQc
May 29, 2007

shrughes posted:

Do you like, actually program? Because this is retarded.

first, yes I do...

Look it's not that hard:

code:
 1 2 3 4 5 6 7 8   <-- position
[a b c d e f g h]
0 1 2 3 4 5 6 7    <-- offset
a is the first element, b is the second, c is the third. There's usually a given order, I can reasonably ask for these positions, the same way I may ask for the page or the chapter of a book.

If I ask for an offset, I'm going for what is basically "the number of elements preceding in the sequence". If I'm iterating over the array and need an index, I'll be interested by what is basically "how many elements I've seen before", not necessarily "element at position x".

The two definitions are fairly similar, but not identical, and not overlapping either.
I've never been pissed or overtly angry at seeing either being picked by a language as long as the operations attached match the indexing picked.

now if you want to get into the debate of ranges, that's a fun one too.

tef
May 30, 2004

-> some l-system crap ->
whiny c programmers can keep their offsets and pointer addresses. don't need em for kids to make poop joke games

Luigi Thirty
Apr 30, 2006

Emergency confection port.

pre:
a t s i b b y
[i t s y o u]
 u i t c a b

shrughes
Oct 11, 2008

(call/cc call/cc)

MononcQc posted:

code:
 1 2 3 4 5 6 7 8   <-- position
[a b c d e f g h]
0 1 2 3 4 5 6 7    <-- offset

No.

code:
 0 1 2 3 4 5 6 7   <-- position
[a b c d e f g h]
0 1 2 3 4 5 6 7    <-- offset

Symbolic Butt
Mar 22, 2009

(_!_)
Buglord

shrughes posted:

No.

code:
 0 1 2 3 4 5 6 7   <-- position
[a b c d e f g h]
0 1 2 3 4 5 6 7    <-- offset

then instead of position think of it as counting.......... jesus gently caress I can't believe I'm discussing this :bang:

Toady
Jan 12, 2009

stop giving a gently caress about this

Sniep
Mar 28, 2004

All I needed was that fatty blunt...



King of Breakfast
i am soooooo bored by this discus

here's a cypher for you, i made it novice level by only using the relevant characters in the cypher

decypher this LAHDSHJKLXTAK

L A H D S H J K L X T A K
↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
B O R I N G F U C K Y O U

Kathleen
Feb 26, 2013

Grimey Drawer

the talent deficit posted:

all you need to know to realize computer science is the worst science is that people get literally angry when someone suggests that maybe zero based indexing - divorced from the context of pointer offsets - maybe doesn't make any sense

idk cs isn't that bad. i just remember that homotopy type theory exists and get all hot and bothered.

coffeetable
Feb 5, 2006

TELL ME AGAIN HOW GREAT BRITAIN WOULD BE IF IT WAS RULED BY THE MERCILESS JACKBOOT OF PRINCE CHARLES

YES I DO TALK TO PLANTS ACTUALLY
next pl thread should have a list of forbidden topics
  • pointers vs offsets
  • weak vs strong typing
  • php

Workaday Wizard
Oct 23, 2009

by Pragmatica

coffeetable posted:

next pl thread should have a list of forbidden topics
  • pointers vs offsets
  • weak vs strong typing
  • php

here is the new thread. just type the following into your browser's navigation toolbar:
about :blank

e: without spaces (radiuuuum?? :arghfist::confused:)

ultramiraculous
Nov 12, 2003

"No..."
Grimey Drawer
what is the name of choco 2.0 and is he doing a teardown on the forums anywhere? lowtax documenting choco's slow descent into madness was one of my favorite parts of this thread.

coffeetable
Feb 5, 2006

TELL ME AGAIN HOW GREAT BRITAIN WOULD BE IF IT WAS RULED BY THE MERCILESS JACKBOOT OF PRINCE CHARLES

YES I DO TALK TO PLANTS ACTUALLY

ultramiraculous posted:

what is the name of choco 2.0 and is he doing a teardown on the forums anywhere? lowtax documenting choco's slow descent into madness was one of my favorite parts of this thread.
most detail so far is
http://forums.somethingawful.com/showthread.php?threadid=3657588&userid=211248

Symbolic Butt
Mar 22, 2009

(_!_)
Buglord
what happened with choco exactly? :ohdear:

coffeetable
Feb 5, 2006

TELL ME AGAIN HOW GREAT BRITAIN WOULD BE IF IT WAS RULED BY THE MERCILESS JACKBOOT OF PRINCE CHARLES

YES I DO TALK TO PLANTS ACTUALLY

Symbolic Butt posted:

what happened with choco exactly? :ohdear:
realised dealing with a decade of some idiot's poo poo code while being paid pennies wasn't worth it, got a better job

Notorious b.s.d.
Jan 25, 2003

by Reene
ruby is not my favorite language

code:
irb(main):001:0> mu = Array.new
=> []
irb(main):002:0> mu.first
=> nil
irb(main):003:0> mu.include?(nil)
=> false	

Symbolic Butt
Mar 22, 2009

(_!_)
Buglord
dealing with nils is the worst part of working with ruby

FamDav
Mar 29, 2008

Notorious b.s.d. posted:

ruby is not my favorite language

code:
irb(main):001:0> mu = Array.new
=> []
irb(main):002:0> mu.first
=> nil
irb(main):003:0> mu.include?(nil)
=> false	

txt me (^_^),-,~
    \

brap
Aug 23, 2004

Grimey Drawer
lol nil != nil somebody should be shot for that

dragon enthusiast
Jan 1, 2010

fleshweasel posted:

lol nil != nil somebody should be shot for that

this also evaluates to false

brap
Aug 23, 2004

Grimey Drawer
doubtless there is some static method you need to look up to use for this relatively common case in programming

reminds me of NaN. NaN is so useless.

Adbot
ADBOT LOVES YOU

dragon enthusiast
Jan 1, 2010
my favorite part of NaN is when compilers optimize out edge cases for dealing with NaNs

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply