PDA

View Full Version : [SOLVED] Integer, Byte or Long for Columns?



Paleo
02-26-2005, 02:23 PM
Hi,

considering excel can manage 65,536 rows and 256 columns, would you agree that a good approach is to use Long data type when refering to rows AND Byte data type when refering to columns (even knowing that our array will never hold all the columns but all less one, as Byte data type can hold only up to 255) because of performance?:dunno

mdmackillop
02-26-2005, 02:29 PM
While it may be technically correct, it's hard enought to explain the code without the reasoning behind the data type. Having read the Microsoft article, I think I'll just go for "long". It's shorter than Integer anyway!

Paleo
02-26-2005, 02:45 PM
Hi MD,

Ok, for rows I would go for "Long" too, my doubt is for columns. Integer, Long or Byte.

Ken Puls
02-26-2005, 02:50 PM
I'm voting Long, (having not read the article,) just in case MS decides to add more columns one day! :giggle

mdmackillop
02-26-2005, 02:52 PM
Given the speed of my typing V the speed of my computer, I think on balance the less characters I type the better. so Columns are Long too.

Paleo
02-26-2005, 03:38 PM
Hi guys,

you know what. Lets make it a poll on columns. What do you think? I am creating it.

Well, so far we all have agreed on Long for rows. :thumb

Jacob Hilderbrand
02-26-2005, 04:16 PM
Why 255?? Anyways Long should be fastest (not that speed matters anymore).

There is no other choice for Rows really. Long is the fastest for Columns as well.

Paleo
02-26-2005, 04:24 PM
Hi guys,

well I proposed 255 columns to make it possible to use Byte and other that who uses that many columns?

I dont think Long is faster than Byte, as it is faster than Integer and Byte requires less memory (only one byte). So why not use it?

Check http://msdn.microsoft.com/library/default.asp?url=/library/en-us/modcore/html/decontheintegerdatatypes.asp

Paleo
02-26-2005, 04:27 PM
Are you sure its faster than Byte? Remember that byte costs less memory.

johnske
02-26-2005, 08:36 PM
I always try to work with the KISS principle, it's easier to just put long for both rather than having to think - 'now, was it long for columns and byte for rows or was that the other way round?' :devil:

After reading the article & the other comments, I agree that any speed and/or memory saving is inconsequental with modern computers, so, Keep It Simple = "Long" for me from now on...

Jacob Hilderbrand
02-26-2005, 08:45 PM
If you are writing code you should account for all posibilities. You assume that someone would not use the code for 256 columns so you use Byte, but Byte can only go up to 255 and in a loop only to 254 without error handling.

You could use Integer for rows and just assume nobody would ever use more than 32,768 rows, but why limit your self.

And even if Byte is technically faster, stop and think for a minute about what difference it actually makes. If you are looping 1000's of times we are still only talking about a small fraction of a second difference.

Paleo
02-26-2005, 09:28 PM
Gee,ok Jake, you won again. You right, I choose Long too. Thanks guys.

Sorry, for insisting in it but this way I just have learned more. I have readen that article from MS and got in doubt, but now thanks for the support from all of you my doubt is gone. I understood Long is better.

Thanks guys.

Ivan F Moala
02-27-2005, 05:56 AM
Hi guys,

well I proposed 255 columns to make it possible to use Byte and other that who uses that many columns?

I dont think Long is faster than Byte, as it is faster than Integer and Byte requires less memory (only one byte). So why not use it?

Check http://msdn.microsoft.com/library/default.asp?url=/library/en-us/modcore/html/decontheintegerdatatypes.asp

Using the Byte data type is NOT faster then the Long.
Dermot balsome has a workbook displaying this here ....

http://www.webace.com.au/~balson/InsaneExcel/Other.htm

Speed of different variable types (new)

On tests I done long was faster then integer by around 12% and faster then Byte by a whopping 44%. I would have expected this as there is less conversion from Integer to long as from Byte to long. VBA Op codes are 32bit data types so the less conversion the faster the op.

Paleo
02-27-2005, 08:13 AM
Hi Ivan,

well looks like I was VERY mistaken on that... Anyway now I have learned more things on it.

Richie(UK)
02-27-2005, 10:52 AM
Hi Carlos,

I realise that this thread is marked as 'Solved' but I thought I'd add my 2p worth anyway ;)

Just based upon experience I would have suggested that Longs would have been quicker (and this has been proved to be the case in the responses detailed above).

However, I think the key point here has been made by Jake - for the sake of a fraction of a second in most cases, performance isn't really an important factor. It's far more important to concentrate on the integrity and maintainability of your code - assume that users will do things that you have asked them not to. :) At the end of the day we should try to use whatever data type is most appropriate for the scenario, not necessarily which one will be the fastest.

Paleo
02-27-2005, 11:43 AM
Hi Richie,

agreed on that with you. My point was Byte is less memory consuming not necessarily faster, so you could work with bigger workbooks on weaker computers, but I think you all right. Long is better by being faster and most appropriate for the scenario.

Thanks guys.

Anne Troy
02-27-2005, 11:45 AM
assume that users will do things that you have asked them not to.

Now, come on!!
When has that EVER happened to anybody?? Users ALWAYS do exactly what you tell them!!

:rofl :rofl :rofl :rofl

Paleo
02-27-2005, 11:47 AM
Now, come on!!
When has that EVER happened to anybody?? Users ALWAYS do exactly what you tell them!!

:rofl :rofl :rofl :rofl

Users, our nightmare:devil: :devil: :rofl

Howard Kaikow
02-27-2005, 12:42 PM
Gee,ok Jake, you won again. You right, I choose Long too. Thanks guys.

Sorry, for insisting in it but this way I just have learned more. I have readen that article from MS and got in doubt, but now thanks for the support from all of you my doubt is gone. I understood Long is better.

Thanks guys.

long is faster than either integer or byte, not to mention that the word objects/properties use longs for column numbers, so why cause needless conversions.

Paleo
02-27-2005, 12:49 PM
Hi Howard,

it was just a memory issue, but thats okay, I have learned I was wrong, even if we dont feel the performance improvement the impact on memory can be less dangerous than what a user can do...

Howard Kaikow
02-27-2005, 01:14 PM
Hi Howard,

it was just a memory issue, but thats okay, I have learned I was wrong, even if we dont feel the performance improvement the impact on memory can be less dangerous than what a user can do...

in general, memory issues come into play when dealing with large arrays and with recursive algorithms.

but memory should not be a concern for variables that are used only to index something, especially when you know the values cannot be be greater than 255.

Using the program at http://www.standards.com/index.html?Sorting, I've sorted arrays of 50 000 000 elements, perhaps even 60 000 000, without using virtual memory. System has 768MB memory.

Paleo
02-27-2005, 01:22 PM
Hi Howard,

gee thats a great program, congrats. As I dont have any database that big, could you point a place where I may download one of those or send it by e-mail to me?

Howard Kaikow
02-27-2005, 01:58 PM
Hi Howard,

gee thats a great program, congrats. As I dont have any database that big, could you point a place where I may download one of those or send it by e-mail to me?

The program at http://www.standards.com/index.html?Sorting generates the test data.

I have made available some of the Sorting code, but not the code for the Form,

Paleo
02-27-2005, 02:07 PM
Great, thanks. So I will install and use it. Is it freeware?

Ken Wright
02-28-2005, 01:16 PM
There is no real reason to use Integer anymore, as later versions of Excel will convert it to Long anyway, so you are probably more efficient using Long:-

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/modcore/html/decontheintegerdatatypes.asp

Regards
Ken.............

Anne Troy
02-28-2005, 02:01 PM
Ken, baby!
:bigkiss:

Ken Wright
02-28-2005, 02:06 PM
[Blushes] - Right back at you with that Kiss :*)

Paleo
02-28-2005, 09:07 PM
Hi Ken,

I wasnt telling people to the possibility of using Integer, but for the possibility of using Byte instead because it needs less memory than Integer or Long.

Zack Barresse
02-28-2005, 10:09 PM
Use Byte (sometimes) if/when using String arrays. There is your Byte speed. Although some good discussion can be insued as to the actual spesed of it or not. A lot of conversation - both ways.

Paleo
03-01-2005, 11:11 AM
Hi Zack,

yes I think its a lot better than String for string arrays, too. Thanks.