Imagine a world...

Discussion in 'Chit Chat' started by wonder, Feb 10, 2015.

  1. wonder

    wonder Expert Licensed User

    ...where the first position of an array is 1 and not 0.
    Code:
    Dim a(10as Int

    For i = 1 to 10
         label1.text = label1.text & a(i) & 
    crlf
    Next
    World peace achieved, no more war, hunger or misery on the planet. Humanity is united. Perfect utopia.

    Hell yeah!!!! :cool::D
     
    KMatle, Erel and inakigarm like this.
  2. lemonisdead

    lemonisdead Well-Known Member Licensed User

    ??? :p
     
  3. wonder

    wonder Expert Licensed User

    [​IMG]

    If I had a dollar for every time I make this mistake, I'd buy Apple, Google, Microsoft, McDonalds and Coca-Cola (the companies).
     
    Peter Simpson and lemonisdead like this.
  4. lemonisdead

    lemonisdead Well-Known Member Licensed User

    Well, I do have a solution for you : remember that your school teacher lied to you !
    Should be better and you will be able to buy those companies :D
     
  5. NJDude

    NJDude Expert Licensed User

    The solution is very simple, pay attention to the language you're using ;)
     
    KitCarlson and lemonisdead like this.
  6. lemonisdead

    lemonisdead Well-Known Member Licensed User

    Do you mean some languages won't use 0 as a value ?
     
  7. NJDude

    NJDude Expert Licensed User

    Some languages are ZERO based others don't, you as a developer should know that as you learn the new language.
     
  8. lemonisdead

    lemonisdead Well-Known Member Licensed User

    Damned, I even don't know where I have put the keys of my car ;)
    Should I PM a kind IT guy to remember me

    But, I wonder why not all languages don't use the ZERO as a base. It spoils the memory :rolleyes:
     
  9. wonder

    wonder Expert Licensed User

    If I good remember, all languages I used before use 0 to index the first position of an array...
    Which languages use 1? I'm curious! :)
     
    lemonisdead likes this.
  10. NJDude

    NJDude Expert Licensed User

    Well, let's find out HERE :D
     
    RandomCoder and lemonisdead like this.
  11. lemonisdead

    lemonisdead Well-Known Member Licensed User

    Eh, eh... I wanted to find some but... I only got an PC AT guy saying he didn't know about [​IMG]
     
    wonder likes this.
  12. NJDude

    NJDude Expert Licensed User

    Ok, then check HERE
     
  13. lemonisdead

    lemonisdead Well-Known Member Licensed User

    Well, I am going to learn ALGOL68 (it is a nice name, isn't it)... I notice that the major known languages are zero based. Awesome [​IMG]
     
    wonder, RandomCoder and NJDude like this.
  14. RandomCoder

    RandomCoder Well-Known Member Licensed User

    MATLAB now there's a blast from my Engineering Uni days :mad:
     
  15. wonder

    wonder Expert Licensed User

    The screenshots of MATLAB do look really cool!
     
    lemonisdead likes this.
  16. Daestrum

    Daestrum Well-Known Member Licensed User

    Visual Basic has 'option base 1' to change the default base for arrays (if I remember correctly) from 0 to 1
     
    lemonisdead likes this.
  17. Peter Simpson

    Peter Simpson Expert Licensed User

    This discussion started off as a little bit if fun and has now turned way too serious for me.

    Zero based. Hmm base, base, bass, bass, bass, bass :)

    I think that I'll turn on my Ref Hi-Fi and listen to some smooth soul music before going to sleep.

    Night all...
     
    lemonisdead likes this.
  18. Beja

    Beja Expert Licensed User

    It's normal to start from zero.. when you travel you start from mile zero, right? Mile one is one mile away (Duh!)
    But,
    if you started from mile 1 then you will end your trip 1 mile past your destination and you need to make a U-turn, and you will never
    be able to stop at the destination, and will U-turn until tomorrow.
     
    lemonisdead likes this.
  19. WAZUMBi

    WAZUMBi Well-Known Member Licensed User

    I once tried to implement OPTION BASE in a program and it confused the hell out of me. It literally gave me nightmares.
    Stick with zero....
     
    RandomCoder likes this.
  20. Troberg

    Troberg Well-Known Member Licensed User

    I don't care either way, althoug, occasionally, it would be nice to be able to set any base, such as:

    Dim Year(1900 to 2100) as int

    This way, by the way, is how i declare every array in VB, with an explicit lower boundary, even if it is 0, just to be clear.

    To be honest, though, I think the 0 based arrays are a leftover from when memory space was a real issue, and by starting with 0, you gained another possible slot with the same size variable. Now, you can just slap a 32 or 64 bit int there and store as many items as you like, because a few bytes more is neglible (and, in some cases, preferable, as the CPU may be faster with types equal to the data bus width, and probably allocates that much for a variable anyway).
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice