|
From: Stan Weiss on 21 May 2008 12:16 Is there any difference in speed between these 2 methods? In .BAS Module Global Const MPH_TO_FPS = 5280 / 3600 'Convert MPH to Feet per Second In .FRM File ans14 = MPH1 * MPH_TO_FPS 'Vel. (ft/sec) and ans14 = MPH1 * 5280 / 3600 'Vel. (ft/sec)
From: Jim Mack on 21 May 2008 11:53 Stan Weiss wrote: > Is there any difference in speed between these 2 methods? > > In .BAS Module > Global Const MPH_TO_FPS = 5280 / 3600 'Convert MPH to Feet per Second > In .FRM File > ans14 = MPH1 * MPH_TO_FPS 'Vel. (ft/sec) > > and > ans14 = MPH1 * 5280 / 3600 'Vel. (ft/sec) If you only do it once, then it hardly matters. If you do it repeatedly then the first is better because it involves only one FP operation. BUT: if you haven't typed the variables and constants, then you'll get Variants, so wondering about speed is pointless. (-: If you're using Singles, then type everything as such: Global Const MPH_TO_FPS As Single = 5280 / 3600 .. .. Dim ans14 As Single Dim MPH1 As Single ans14 = MPH1 * MPH_TO_FPS -- Jim Mack MicroDexterity Inc www.microdexterity.com
From: Stan Weiss on 21 May 2008 13:07 Jim Mack wrote: > > Stan Weiss wrote: > > Is there any difference in speed between these 2 methods? > > > > In .BAS Module > > Global Const MPH_TO_FPS = 5280 / 3600 > 'Convert MPH to Feet per Second > > In .FRM File > > ans14 = MPH1 * MPH_TO_FPS 'Vel. (ft/sec) > > > > and > > ans14 = MPH1 * 5280 / 3600 'Vel. (ft/sec) > > If you only do it once, then it hardly matters. If you do it > repeatedly then the first is better because it involves only one FP > operation. > > BUT: if you haven't typed the variables and constants, then you'll get > Variants, so wondering about speed is pointless. (-: > > If you're using Singles, then type everything as such: > > Global Const MPH_TO_FPS As Single = 5280 / 3600 > > .. > .. > > Dim ans14 As Single > Dim MPH1 As Single > > ans14 = MPH1 * MPH_TO_FPS > > -- > Jim Mack > MicroDexterity Inc > www.microdexterity.com Thanks this will be in a loop and these are defined as Dim ans14 As Double Dim MPH1 As Double
From: Jim Mack on 21 May 2008 12:14 Stan Weiss wrote: >> Jim Mack wrote: > >> If you're using Singles, then type everything as such: >> >> Global Const MPH_TO_FPS As Single = 5280 / 3600 >> >> .. >> .. >> >> Dim ans14 As Single >> Dim MPH1 As Single >> >> ans14 = MPH1 * MPH_TO_FPS > > > Thanks this will be in a loop and these are defined as > Dim ans14 As Double > Dim MPH1 As Double Then type the constant as Double too. But you will get better speed using all Singles if you don't need the extra precision -- and almost nothing that models the real world (like MPH) requires Doubles. -- Jim Mack MicroDexterity Inc www.microdexterity.com
From: Stan Weiss on 21 May 2008 13:31 Jim Mack wrote: > > Stan Weiss wrote: > >> Jim Mack wrote: > > > >> If you're using Singles, then type everything as such: > >> > >> Global Const MPH_TO_FPS As Single = 5280 / 3600 > >> > >> .. > >> .. > >> > >> Dim ans14 As Single > >> Dim MPH1 As Single > >> > >> ans14 = MPH1 * MPH_TO_FPS > > > > > > Thanks this will be in a loop and these are defined as > > Dim ans14 As Double > > Dim MPH1 As Double > > Then type the constant as Double too. But you will get better speed > using all Singles if you don't need the extra precision -- and almost > nothing that models the real world (like MPH) requires Doubles. > > -- > Jim Mack > MicroDexterity Inc > www.microdexterity.com The reason for using double is the customer wants to see 12 decimal places. Thanks Again, Stan
|
Next
|
Last
Pages: 1 2 Prev: how to open an excel template (xlt)? Next: Newbie Q: Multi User Access |