From: Claire on
I want to do that just as you'd do it, Mike.
I know, that each routine works but I would like to know which one is more
efficient(?) ,vbasic classic standard(?), politically correct(?)
I have a hardware device which generates a beep every 2 seconds.
My code is interfacing it and I want to change those beeps into the digital
number.
Thats all.
Thanks,
Claire

"MikeD" <nobody(a)nowhere.edu> wrote in message
news:uIcabjdBLHA.4400(a)TK2MSFTNGP05.phx.gbl...
>
>
> "Claire" <replyto(a)fra> wrote in message
> news:eW9byJcBLHA.5848(a)TK2MSFTNGP06.phx.gbl...
>> Hello,
>> If I have a variable declared as Long:
>>
>> Dim RingCount as Long
>>
>> can I do this:
>> RingCount = Int((Timer - StartDial) / 2)
>> or should I do this:
>> RingCount = Abs((Timer - StartDial) / 2)
>> or do this:
>> RingCount = (Timer - StartDial) \ 2
>>
>> Which one will be the best approach?
>>
>
>
> What is that you're ultimately wanting? You can do any of those 3 things,
> but without knowing the ultimate goal, it's impossible to tell you which
> of those 3 choices, or something else, would be best.
>
>
>


From: dpb on
Claire wrote:
....[top posting repaired...don't do that makes hard post follow]...
> "MikeD" <nobody(a)nowhere.edu> wrote in message
> news:uIcabjdBLHA.4400(a)TK2MSFTNGP05.phx.gbl...
>>
>> "Claire" <replyto(a)fra> wrote in message
>> news:eW9byJcBLHA.5848(a)TK2MSFTNGP06.phx.gbl...
>>> Hello,
>>> If I have a variable declared as Long:
>>>
>>> Dim RingCount as Long
>>>
>>> can I do this:
>>> RingCount = Int((Timer - StartDial) / 2)
>>> or should I do this:
>>> RingCount = Abs((Timer - StartDial) / 2)
>>> or do this:
>>> RingCount = (Timer - StartDial) \ 2
>>>
>>> Which one will be the best approach?
>>>
>>
>> What is that you're ultimately wanting? You can do any of those 3 things,
>> but without knowing the ultimate goal, it's impossible to tell you which
>> of those 3 choices, or something else, would be best.

> I want to do that just as you'd do it, Mike.
> I know, that each routine works but I would like to know which one is
> more> efficient(?) ,vbasic classic standard(?), politically
> correct(?)
> I have a hardware device which generates a beep every 2 seconds.
> My code is interfacing it and I want to change those beeps into the
> digital number.
....

Doesn't answer the question -- _WHAT_ number is the object?

As for the other questions, I'm not much into metaphysics...

--
From: Cor Ligthert[MVP] on
Claire,

You mostly don't know which code is used behind the scene to accomplish what
you want.

However, if we take your cod, then the integer divide needs the less
conversions, so that would in my idea be the most preferable.

Cor


"Claire" <replyto(a)fra> wrote in message
news:#ZAe7yeBLHA.980(a)TK2MSFTNGP04.phx.gbl...
> I want to do that just as you'd do it, Mike.
> I know, that each routine works but I would like to know which one is more
> efficient(?) ,vbasic classic standard(?), politically correct(?)
> I have a hardware device which generates a beep every 2 seconds.
> My code is interfacing it and I want to change those beeps into the
> digital number.
> Thats all.
> Thanks,
> Claire
>
> "MikeD" <nobody(a)nowhere.edu> wrote in message
> news:uIcabjdBLHA.4400(a)TK2MSFTNGP05.phx.gbl...
>>
>>
>> "Claire" <replyto(a)fra> wrote in message
>> news:eW9byJcBLHA.5848(a)TK2MSFTNGP06.phx.gbl...
>>> Hello,
>>> If I have a variable declared as Long:
>>>
>>> Dim RingCount as Long
>>>
>>> can I do this:
>>> RingCount = Int((Timer - StartDial) / 2)
>>> or should I do this:
>>> RingCount = Abs((Timer - StartDial) / 2)
>>> or do this:
>>> RingCount = (Timer - StartDial) \ 2
>>>
>>> Which one will be the best approach?
>>>
>>
>>
>> What is that you're ultimately wanting? You can do any of those 3 things,
>> but without knowing the ultimate goal, it's impossible to tell you which
>> of those 3 choices, or something else, would be best.
>>
>>
>>
>
>
>
From: Mike Williams on
"Claire" <replyto(a)fra> wrote in message
news:%23ZAe7yeBLHA.980(a)TK2MSFTNGP04.phx.gbl...

> RingCount = Int((Timer - StartDial) / 2)
> RingCount = Abs((Timer - StartDial) / 2)
> RingCount = (Timer - StartDial) \ 2
> RingCount is a Long and StartDial is a Double
> I am not concerned about Timer rolling over at midnight
> I know, that each routine works but I would
> like to know which one is more efficient(?)

If you mean in terms of speed then it doesn't really matter which one you
use (although I would advise you to add code to account for rollover
regardless of the fact that you have said you don't need it at the moment,
and I would probably avoid Abs in this particular case). RingCount =
(Timer - StartDial) \ 2 would probably be the fastest, but not by a
significant amount, partly because there are type conversions going on in
all cases but mainly because the math and the type conversions do not
actually take a significant part of the total execution time, with the Timer
function itself taking probably about 80 per cent of the overall time. If
you want speed then get rid of the Timer function. Having said that, even as
it stands (with the Timer function) you're talking about something in the
region of a quarter of a microsecnd to execute the complete line, and so
unless you are executing this line of code at very short intervals then it
really isn't going to make much difference.

Mike



First  |  Prev  | 
Pages: 1 2
Prev: Newsreader Mayhem!
Next: Terminating an endless loop