From: Stan Weiss on
Is there any difference in speed between these 2 methods?

In .BAS Module
Global ans1 As Double
Global ans10 As Double
Global ans14 As Double
Global Const DEG_TO_RAD As Double = kPI / 180# 'Convert Degrees to
RAD's

--- First Method
In .FRM File in a Loop
ans14 = ans1 * DEG_TO_RAD

--- Second Method
In .FRM File
ans10 = kPI / 180#

In .FRM File in a Loop
ans14 = ans1 * ans10
From: Auric__ on
On Thu, 22 May 2008 18:22:35 GMT, Stan Weiss wrote:

> Is there any difference in speed between these 2 methods?
>
> In .BAS Module
> Global ans1 As Double
> Global ans10 As Double
> Global ans14 As Double
> Global Const DEG_TO_RAD As Double = kPI / 180# 'Convert Degrees to
> RAD's
>
> --- First Method
> In .FRM File in a Loop
> ans14 = ans1 * DEG_TO_RAD
>
> --- Second Method
> In .FRM File
> ans10 = kPI / 180#
>
> In .FRM File in a Loop
> ans14 = ans1 * ans10

Any time you can use a constant number, it's *always* faster to just use
the constant than to recalculate the number each time.

In this particular case, the first method calculates DEG_TO_RAD once, at
compile time, while the second method calculates it each time "ans10 =
kPI / 180#" is hit. If that line only happens once during the program
then the time hit is probably not noticeable (by humans, anyway)... but
if you already have DEG_TO_RAD declared anyway, why not just use it?

--
Where did you get this 60Hz ground hum you call brain activity?