我正在尝试将小数转换为分数,例如,我写了一些东西var _pow:int = Math.pow(base,i)
,如果i
结果是负数,它会给出一个小数(例如:3 ^ -2),我是目前被困在试图找到一种方法将 _pow 变成分数(所以 _pow 超出 100)所以我尝试这样做var _pow:int = Math.pow(base,i) * 100
应该阻止它成为小数,但它没有显示在动态文本中,而且这只发生在i
负数时
package{
import flash.display.*;
import flash.events.MouseEvent;
public class name_ extends MovieClip{
public function _name_(){
btn.addEventListener(MouseEvent.CLICK, input)
base.restrict = "0-9\\.\\-";
pow.restrict = "0-9\\.\\-";
answer.multiline = true;
}
private function input(event:MouseEvent):void{
var pow = pow.text;
var base = base.text;
var answerText:String = "";
if(pow > 0){
for(var i = 1; i <= pow; i++){
_pow = Math.pow(base,i);
answerText += ("\n" + base + " exposant(power) " + i + " = "+ _pow );
answer.text = answerText;
}
}else{
for(i = 1; i <= pow; i++){
var _pow:int = Math.pow(base,i) * 100
answerText += ("\n" + base + " exposant(power) " + i + " = "+ _pow );
answer.text = answerText; //Dynamic text
}
}
}
}
}