Re: String or Numeric Variable?
- From: "Alfie [UK]" <me@xxxxxxxxxxx>
- Date: Sat, 29 Oct 2005 20:00:08 +0100
On Sat, 29 Oct 2005 09:25:02 -0500, "ProfitMaxTrading.com"
<nospam@xxxxxxxxxx> wrote:
>What I believe you are referring to is Zero-Extension or Sign-Extension. A
>1-byte value such as &H7F thus becomes &H007F or &H0000007F, etc.?
>
>Then this begs another question.
>
>1. Why bother even having a BYTE type, or an INTEGER type?
>
>If we can simply substitute a LONG type for the other two, that would make
>typing that much easier.
>
>Can you think of examples where this would not be the case?
>
There are some situations where you will need to use other data types,
some Windows functions and APIs for instance, UDT interfaces into DBs,
etc.
In the early days of programming there was often a trade off between the
speed or size of an APP, but as we saw with other examples the speed
differences between datatypes only really makes a difference when
calculations or compares are being carried out over 1,000s of times a
second and memory footprint is not as big an issue as it used to be.
In most data structures there is no memory alignment of the elements so
an array of BYTEs will be smaller in memory than an array of LONGs. BYTE
arrays also have other processing usages, for instance in bitmap
manipulation.
You only really have to 'worry' about memory alignment when using UDTs,
you have to take care to avoid unnecessary padding, for instance;
Type TestA ' size = 3 bytes
a as BYTE
b as BYTE
c as BYTE
End Type
Type TestB ' size = 12 bytes
a as BYTE
b as LONG
c as BYTE
End Type
Type TestC ' size = 8 bytes
a as BYTE
b as BYTE
c as LONG
End Type
--
Alfie
<http://www.delphia.co.uk/>
Give a man a beer he wastes an hour...Teach a man to brew and he wastes a lifetime
.
- Follow-Ups:
- Re: String or Numeric Variable?
- From: ProfitMaxTrading.com
- Re: String or Numeric Variable?
- References:
- String or Numeric Variable?
- From: ProfitMaxTrading.com
- Re: String or Numeric Variable?
- From: ProfitMaxTrading.com
- Re: String or Numeric Variable?
- From: Howard Henry Schlunder
- Re: String or Numeric Variable?
- From: ProfitMaxTrading.com
- String or Numeric Variable?
- Prev by Date: Labels
- Next by Date: Re: String or Numeric Variable?
- Previous by thread: Re: String or Numeric Variable?
- Next by thread: Re: String or Numeric Variable?
- Index(es):