Re: String or Numeric Variable?
- From: "ProfitMaxTrading.com" <nospam@xxxxxxxxxx>
- Date: Fri, 28 Oct 2005 14:59:11 -0500
Hi Mike.
Thanks for your comments.
Okay, it appears that using numeric constants will solve the 'readability'
issue and Enum (Fernando's comment) perhaps more efficient? So I'll go with
the numeric route rather than string because I have a ton of these
IF..THENS that work off these all through the program.
But you mentioned LONG as opposed to BYTE or INTEGER. Are you saying that a
LONG type is better for even single-digit numbers used for nothing more than
comparisons (as opposed to having math performed on them) than a BYTE or
INTEGER type?
Obviously the BYTE or INTEGER type would use less memory. But I suppose not
a big deal if you don't over do it. But just why is LONG better?
Thanks.
"Mike Williams" <Mike@xxxxxxxxxxxxxxxxx> wrote in message
news:djtoub$ntj$1@xxxxxxxxxxxxxxxxxxxxxxx
> "ProfitMaxTrading.com" <nospam@xxxxxxxxxx> wrote in message
> news:h2t8f.3642$LR1.1843@xxxxxxxxxxxxx
>
>> Is it best to use a variable of type string and either have it equal
>> "Morning", "Afternoon" or "Night" or "M", "A", "N" for example
>> or perhaps a numeric variable, say type BYTE and give it values
>> of 1, 2 or 3 to mean the same?
>
> It depends what you are doing with it, and how many times you have to
> access it throughout the program. Using a standard integer variable (Byte,
> Integer or Long) is definitely much faster than a string (with Long
> probably being the faster of the three integer types). But, in many cases
> speed really isn't an issue, and the descriptive nature of a string can
> often make your code much more "readable". For example:
>
> If TimeOfDay = "Night" Then . . .
>
> is much more readable than . . .
>
> if TimeofDay = 1 Then . . .
>
> and it is certainly much more readable than using bits as flags and
> checking them. Basically, do what you're most comfortable with. I
> personally like code that makes sense when I read it, even if it does take
> a few more nanoseconds to execute. The exception, of course, is when you
> are using variables in a loop that is going to be executed a very large
> number of times and where speed is of the esscence. Then you would use
> whatever happens to be the fastest in that specific case.
>
> Mike
>
>
>
.
- Follow-Ups:
- Re: String or Numeric Variable?
- From: Howard Henry Schlunder
- Re: String or Numeric Variable?
- From: Alfie [UK]
- Re: String or Numeric Variable?
- From: Mike Williams
- Re: String or Numeric Variable?
- References:
- String or Numeric Variable?
- From: ProfitMaxTrading.com
- String or Numeric Variable?
- Prev by Date: Re: String or Numeric Variable?
- 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):
Relevant Pages
|