Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi All,
I come from a day when storage was a LOT dearer than it is today. I use Integer or Long for whole # values 'cuz I read once that Integer takes less memory. It's also kind of self documenting about the size of the #. With memory gigs now about the size of a thumbnail, what are the major pro's and cons of still using As Integer versus As Long. Thanks. -- Neal Z |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
In 32 bit machines generally there's no advantage to using As Integer. If
anything there's an extra overhead involved as behind the scenes it gets converted to a Long for storage, then back to an Integer again for use. There are some built-in Event stubs which expect Integer arguments. You can still pass your as Long variable though the value must not exceed +/-32k, it might be worth declaring your variable As Integer to will help flag any errors. There are one or two API's that expect an Integer value or variable. Regards, Peter T "Neal Zimm" wrote in message ... Hi All, I come from a day when storage was a LOT dearer than it is today. I use Integer or Long for whole # values 'cuz I read once that Integer takes less memory. It's also kind of self documenting about the size of the #. With memory gigs now about the size of a thumbnail, what are the major pro's and cons of still using As Integer versus As Long. Thanks. -- Neal Z |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
thanks much peter.
-- Neal Z "Peter T" wrote: In 32 bit machines generally there's no advantage to using As Integer. If anything there's an extra overhead involved as behind the scenes it gets converted to a Long for storage, then back to an Integer again for use. There are some built-in Event stubs which expect Integer arguments. You can still pass your as Long variable though the value must not exceed +/-32k, it might be worth declaring your variable As Integer to will help flag any errors. There are one or two API's that expect an Integer value or variable. Regards, Peter T "Neal Zimm" wrote in message ... Hi All, I come from a day when storage was a LOT dearer than it is today. I use Integer or Long for whole # values 'cuz I read once that Integer takes less memory. It's also kind of self documenting about the size of the #. With memory gigs now about the size of a thumbnail, what are the major pro's and cons of still using As Integer versus As Long. Thanks. -- Neal Z . |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Deep behind the scenes, Integers are converted to Longs, since a
32-bit integer is the coin of the realm of (32-bit) processors. Memory is so cheap (I recently bought 8 GB for a small fraction of what I originally paid to upgrade 4 MB to 8 MB back in the day) that you don't really have to worry about optimizing memory usage. Moreover, if you are really that concerned about memory usage, VBA is definitely the wrong language to be using in the first place. With rare exceptions, you can completely disregard Integers and Singles and always use Longs and Doubles. Cordially, Chip Pearson Microsoft MVP 1998 - 2010 Pearson Software Consulting, LLC www.cpearson.com [email on web site] On Sat, 13 Feb 2010 05:31:01 -0800, Neal Zimm wrote: Hi All, I come from a day when storage was a LOT dearer than it is today. I use Integer or Long for whole # values 'cuz I read once that Integer takes less memory. It's also kind of self documenting about the size of the #. With memory gigs now about the size of a thumbnail, what are the major pro's and cons of still using As Integer versus As Long. Thanks. |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks Chip
-- Neal Z "Chip Pearson" wrote: Deep behind the scenes, Integers are converted to Longs, since a 32-bit integer is the coin of the realm of (32-bit) processors. Memory is so cheap (I recently bought 8 GB for a small fraction of what I originally paid to upgrade 4 MB to 8 MB back in the day) that you don't really have to worry about optimizing memory usage. Moreover, if you are really that concerned about memory usage, VBA is definitely the wrong language to be using in the first place. With rare exceptions, you can completely disregard Integers and Singles and always use Longs and Doubles. Cordially, Chip Pearson Microsoft MVP 1998 - 2010 Pearson Software Consulting, LLC www.cpearson.com [email on web site] On Sat, 13 Feb 2010 05:31:01 -0800, Neal Zimm wrote: Hi All, I come from a day when storage was a LOT dearer than it is today. I use Integer or Long for whole # values 'cuz I read once that Integer takes less memory. It's also kind of self documenting about the size of the #. With memory gigs now about the size of a thumbnail, what are the major pro's and cons of still using As Integer versus As Long. Thanks. . |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
hi
none really. an integer is 1 byte, a long is 2 bytes. when dos first came out and IMB decided that 64000 byte would be all the memory anyone would ever need, 1 byte may have been signifcant but today where memory is measured in megabyes and gigabyles, 1 byte is insignificant. an integer will represent a number value of 32767(pos or neg). the number value of today's date is 40222 meaning you would get overflow errors trying to assign a date to a variable dimmed as an integer. personally i never use integer anymore. in vb help, type in "data types" and view the table of data types. the largest is variant which is about 20 bytes which in my opion is still fairly insignificant. I wouldn't really worry about it anymore. only if and when you do get an overflow error would you need to think about it. regards FSt1 "Neal Zimm" wrote: Hi All, I come from a day when storage was a LOT dearer than it is today. I use Integer or Long for whole # values 'cuz I read once that Integer takes less memory. It's also kind of self documenting about the size of the #. With memory gigs now about the size of a thumbnail, what are the major pro's and cons of still using As Integer versus As Long. Thanks. -- Neal Z |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
thanks much.
-- Neal Z "FSt1" wrote: hi none really. an integer is 1 byte, a long is 2 bytes. when dos first came out and IMB decided that 64000 byte would be all the memory anyone would ever need, 1 byte may have been signifcant but today where memory is measured in megabyes and gigabyles, 1 byte is insignificant. an integer will represent a number value of 32767(pos or neg). the number value of today's date is 40222 meaning you would get overflow errors trying to assign a date to a variable dimmed as an integer. personally i never use integer anymore. in vb help, type in "data types" and view the table of data types. the largest is variant which is about 20 bytes which in my opion is still fairly insignificant. I wouldn't really worry about it anymore. only if and when you do get an overflow error would you need to think about it. regards FSt1 "Neal Zimm" wrote: Hi All, I come from a day when storage was a LOT dearer than it is today. I use Integer or Long for whole # values 'cuz I read once that Integer takes less memory. It's also kind of self documenting about the size of the #. With memory gigs now about the size of a thumbnail, what are the major pro's and cons of still using As Integer versus As Long. Thanks. -- Neal Z |
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() none really. an integer is 1 byte, a long is 2 bytes. An Integer is two bytes, Long is four bytes. largest is variant which is about 20 bytes which in my opion is still fairly insignificant. True enough, but there is a lot of processing overhead with a Variant, so it should be avoided not so much for the purposes of minimizing memory but rather because a lot of work has to be done to figure out what type of data is in it and then convert that to the appropriate primitive type. Cordially, Chip Pearson Microsoft MVP 1998 - 2010 Pearson Software Consulting, LLC www.cpearson.com [email on web site] On Sat, 13 Feb 2010 07:15:01 -0800, FSt1 wrote: hi none really. an integer is 1 byte, a long is 2 bytes. when dos first came out and IMB decided that 64000 byte would be all the memory anyone would ever need, 1 byte may have been signifcant but today where memory is measured in megabyes and gigabyles, 1 byte is insignificant. an integer will represent a number value of 32767(pos or neg). the number value of today's date is 40222 meaning you would get overflow errors trying to assign a date to a variable dimmed as an integer. personally i never use integer anymore. in vb help, type in "data types" and view the table of data types. the largest is variant which is about 20 bytes which in my opion is still fairly insignificant. I wouldn't really worry about it anymore. only if and when you do get an overflow error would you need to think about it. regards FSt1 "Neal Zimm" wrote: Hi All, I come from a day when storage was a LOT dearer than it is today. I use Integer or Long for whole # values 'cuz I read once that Integer takes less memory. It's also kind of self documenting about the size of the #. With memory gigs now about the size of a thumbnail, what are the major pro's and cons of still using As Integer versus As Long. Thanks. -- Neal Z |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
VBA code optimization - why using long instead of integer? | Excel Programming | |||
GMT/UTC considerations | Excel Worksheet Functions | |||
Declaring variables (Long, String, Integer) and interpretation spe | Excel Programming | |||
Hash a range, output a Long Integer? | Excel Programming | |||
calculate/concert long/integer to date time | Excel Programming |