forums

TNT Basic Forums > Programming Q&A
what is the command to raise a number to a power?
< Last Thread     Next Thread >
Author
Thread        Post A Reply

01-06-2002 17:08

Posted by:
brett

Click Here to Email brett   Find more posts by brett

i cant find this command in the help files. is it even implimented? if it is tho i really need this! can somone help?

01-07-2002 01:03

Posted by:
Mark Tully

Find more posts by Mark Tully

We confess!

Sorry - that's an obvious omission on our behalf, we forgot to implement a power operator.

You'll have to code one manually until it appears in a future version of TNT Basic. It might make it to the next version (which will be soon).

Somethings like this

' work out 2^7 and store it in myResult
Calc_Power(2,7)
int myResult = result int

procedure Calc_Power(int base, int exp)
int a = 1
int count
for count = 1 to exp
a=a*exp
next
end proc(a)

Hope this helps,

Mark

01-23-2002 23:44

Posted by:
Mark Tully

Find more posts by Mark Tully

Added in TB 1.01

You can now use the ^ operator to raise to the power

eg
print 2^3 ' prints 8

Mark

All times are GMT        Post A Reply

Forum Jump:
< Last Thread     Next Thread >

< Contact Us - TNT Basic >

Powered by: vBulletin Lite Version 1.0.1 Lite
Copyright © Jelsoft Enterprises Limited 2000.