Hello Listers:

Here is a little function I wrote 
to provide an exponentiation operation.
I don't know how many will find this  of use or interest
 but I thought I would post it anyway.



; Function Power
; Returns value of number to the exponent b.
; In ASCII notation, returns  a^b.
; Steve McCaffrey
; August 11, 1999
 
Int Function Power (Int Base, Int Exponent)
var
Int i,
Int p
Let p = 1
Let i = 1
While (i <= Exponent)
Let p = P*Base
Let i = i + 1
EndWhile
Return (p)
EndFunction

You need to give a, and b balues in 
the calling script, such as:
Let a = 3
Let b = 5
You could also create a text file, say in NotePad which had the lines
a: 3
b: 5
and write a function to get these values...but that's another function.

Then the function is called from within  a script with a line such as:

Let p = Power(a,b)
and the input values and output value can be spoken with:

SayInteger (a)
SayString ("raised to the exponent ")
SayInteger (b)
SayString (" is: ")
SayInteger(p)
where a,b, and p are integer variables.

After writing this script, I noted it returned 0 if say you tried to compute
2^50.  Does anyone know what the maximum value of an Int can be?
Also, while I'm on the subject, there seems to be no 
real number division.  that is, the / is integer division.  Is there a way to 
do division with real numbers?
-Thanks.
-Steve








------
Steven McCaffrey
Information Technology Services
NYSED
(518)-473-3453


-
Visit the jfw ml web page: http://jfw.cjb.net

Reply via email to