Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Alphabetic numbering system
Message
 
 
To
08/01/1999 14:13:53
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00174074
Message ID:
00174233
Views:
21
Erik,

You should note that exponentiation is one of the slowest operations for the CPU to execute. Your routines will be a little faster if you just use a simple variable and multiply or divide it by 26 in each iteration. Also the second routine where you store intermediate values takes a lot of unneeded time.

This ends up being quite a bit faster:
FUNCTION Base26ToBase10
LPARA tcStartCode
LOCAL lnResult, i, j

lnResult = 0
j = 1
FOR i = LEN(tcStartCode) TO 1 STEP -1
	lnResult = lnResult + ( ASC( SUBSTR(tcStartCode, i, 1) ) - 65 ) * j
	j = j * 26
ENDFOR

RETURN lnResult
df (was a 10 time MVP)

df FoxPro website
FoxPro Wiki site online, editable knowledgebase
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform