21 lines
380 B
Text
21 lines
380 B
Text
class Exp {
|
|
function : Main(args : String[]) ~ Nil {
|
|
Pow(2,30)->PrintLine();
|
|
Pow(2.0,30)->PrintLine();
|
|
Pow(2.0,-2)->PrintLine();
|
|
}
|
|
|
|
function : native : Pow(base : Float, exp : Int) ~ Float {
|
|
if(exp < 0) {
|
|
return 1 / base->Power(exp * -1.0);
|
|
};
|
|
|
|
ans := 1.0;
|
|
while(exp > 0) {
|
|
ans *= base;
|
|
exp -= 1;
|
|
};
|
|
|
|
return ans;
|
|
}
|
|
}
|