Results 1 to 6 of 6

Thread: [RESOLVED] 64bit index for an array

  1. #1

    Thread Starter
    PowerPoster cicatrix's Avatar
    Join Date
    Dec 2009
    Location
    Moscow, Russia
    Posts
    3,654

    Resolved [RESOLVED] 64bit index for an array

    Can I use Long for array indexing?
    If no what could be done to manipulate large byte arrays (>32bit)?

  2. #2
    Fanatic Member stlaural's Avatar
    Join Date
    Sep 2007
    Location
    Quebec, Canada
    Posts
    683

    Re: 64bit index for an array

    Hey cicatrix, As the Array class has a public property name LongLength I'd say you can.
    I didn't test it though.
    Alex
    .NET developer
    "No. Not even in the face of Armageddon. Never compromise." (Walter Kovacs/Rorschach)

    Things to consider before posting.
    Don't forget to rate the posts if they helped and mark thread as resolved when they are.


    .Net Regex Syntax (Scripting) | .Net Regex Language Element | .Net Regex Class | DateTime format | Framework 4.0: what's new
    My fresh new blog : writingthecode, even if I don't post much.

    System: Intel i7 920, Kingston SSDNow V100 64gig, HDD WD Caviar Black 1TB, External WD "My Book" 500GB, XFX Radeon 4890 XT 1GB, 12 GBs Tri-Channel RAM, 1x27" and 1x23" LCDs, Windows 10 x64, ]VS2015, Framework 3.5 and 4.0

  3. #3
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,290

    Re: 64bit index for an array

    A workaround is to use a 2d array, for example MyArray(1, Integer.MaxValue). As you can see, this array has 2 "rows" and each row has integer.maxvalue elements. So it can hold twice as much data as a single 1d array. Now, to address an element given an int64 value as the index, you can use division and Mod to get the column and row index.

    For example,
    Code:
    Dim myarray(1, integer.maxvalue) as Byte
    
    Dim longIndex as Int64 = 123456789
    Dim column as integer = longindex Mod integer.maxvalue
    Dim row as Integer = longindex \ integer.maxvalue
    Dim myByte as Byte = myarray(row, column)
    Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
    - Abraham Lincoln -

  4. #4
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,109

    Re: 64bit index for an array

    Quote Originally Posted by stanav View Post
    A workaround is to use a 2d array, for example MyArray(1, Integer.MaxValue). As you can see, this array has 2 "rows" and each row has integer.maxvalue elements. So it can hold twice as much data as a single 1d array. Now, to address an element given an int64 value as the index, you can use division and Mod to get the column and row index.
    Welcome back to the days of segment offset memory architecture
    My usual boring signature: Nothing

  5. #5
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,897

    Re: 64bit index for an array

    An array with more memory than my old laptop! Cool.
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  6. #6

    Thread Starter
    PowerPoster cicatrix's Avatar
    Join Date
    Dec 2009
    Location
    Moscow, Russia
    Posts
    3,654

    Re: 64bit index for an array

    Quote Originally Posted by Shaggy Hiker View Post
    Welcome back to the days of segment offset memory architecture
    Exactly. Well. I'll do it this way.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width