Results 1 to 12 of 12

Thread: Whats the difference between...

  1. #1
    Guest
    Can someone explain the difference between :

    Dim MyArray() as byte

    and

    Dim MyArray() as String * 1

    I need to write a long string to an array, and I was wondering which type of array would be more suitable for rapid calculations.

    This will be part of an Encryption DLL so i'll need testers later on if anyone is interested.

    thanks.

  2. #2
    Fanatic Member RealisticGraphics's Avatar
    Join Date
    Jul 1999
    Location
    Arkansas
    Posts
    655
    When you say

    Dim MyArray() as String * 1

    any string you pass to your array will be cut off after the first character. Whereas, if you dim as byte you must pass a ascii number for the character between 0 and 255.

    If you dim as string and then fix the width(as above) the string can be any length that you determine up to 64K(2^16 characters long). For example

    dim mystring as string * 300

    would return a fixed length string 300 characters long.

  3. #3
    Guest

    oops sorry

    I think I didnt explain enough:

    I want to have the long string spread over the entire array, IE. one character per element. I dont mind if i have to convert to numbers, just as long as its fast to run.


  4. #4
    Frenzied Member
    Join Date
    Mar 2000
    Posts
    1,089
    DON'T USE THE SECOND ONE.

    I would use an array of longs and do the strings 4 characters at a time.

    use copymemory to put the string into an array, then we're not using vb strings anymore. (vb strings are fairly slow)
    (if 4 doesn't divide the length of your strings, ie you have a 9 letter string then use 3 longs to store it, you'll be left with 3 null characters at the end of your string when you decrypt it)

    it'll take roughly as long to handle the long integer as it does the byte, but with the long you're handling 4 characters at once so it's nearly 4 times as fast.(probably not 4 in practice)


    the strings will take longer, a string is actually a long pointer to an array of integers, to do a calculation with a string you have to look at the long pointer then look up the integer in question, so that's about half the speed of the byte.

  5. #5
    Hyperactive Member
    Join Date
    Sep 1999
    Location
    Cleveland, Ohio
    Posts
    263
    Find out for yourself; test both and time how long it takes to complete a phrase.

  6. #6
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    I would choose the byte array, it's faster as you use numeric calculations. Also I have a fast algoritm encryption sample and a key encryption on my homepage.
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  7. #7
    Hyperactive Member
    Join Date
    Jun 1999
    Posts
    308
    What is a purpose of doing this?

  8. #8
    Guest
    LG,
    I am creating an encryption algorithm and using an array is the fastest way to do it. Now I need to know what sort of array is manipulated fastest by the CPU.

    Sam,
    I cant use the CopyMemory method because I am using VB to create the DLL, not C++.

    Anyone:
    How do I convert 3 or 4 characters into one Long value?

  9. #9
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    If you're reading or writing from a file you could probably use get and put with a long array. Also, i'm almost sure that integer is fastest, but byte allow me to encrypt strings directly with strconv convertion method
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  10. #10
    Guest
    I'm giving up on this idea because I cant get the algorithm to decrypt properly.

  11. #11
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Paste your algoritm here or send it to me and i'll have a look at what's wrong
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  12. #12
    Guest
    well it works fine when encrypting, its just decrypting that screws up. there is no reason for this that I can see because all you have to do is run the encrypted text through the DLL again and that should be it.

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