Most programming languages have a built-in implementation of exponentiation.



Task

Re-implement integer exponentiation for both   intint   and   floatint   as both a procedure,   and an operator (if your language supports operator definition).

If the language supports operator (or procedure) overloading, then an overloaded form should be provided for both   intint   and   floatint   variants.



Related tasks

   Exponentiation order
   arbitrary-precision integers (included)
   Exponentiation with infix operators in (or operating on) the base


 
Module Exponentiation {
	\\ a variable can be any type except  a string (no $ in name)
	\\ variable b is long type.
	\\ by default we pass by value arguments to a function
	\\ to pass by reference we have to use & before name, 
	\\ in the signature and in the call
	function pow(a, b as long) {
		p=a-a  ' make p same type as a
		p++
		if b>0 then for i=1& to b {p*=a}
		=p
	}
	const fst$="{0::-32} {1}"
	Document exp$
	k= pow(11&, 5)
	exp$=format$(fst$, k, type$(k)="Long")+{
	}
	l=pow(11, 5)
	exp$=format$(fst$, l, type$(l)="Double")+{
	}
	m=pow(pi, 3)
	exp$=format$(fst$, m, type$(m)="Decimal")+{
	}
	\\ send to clipboard
	clipboard exp$
	\\ send  monospaced type text to console using cr char to change lines
	Print #-2, exp$ 
	Rem Report exp$  ' send to console using proportional spacing and justification  
}
Exponentiation
 
 
 