作者aquarianboy (一路好走..)
看板Flash
标题Re: [问题] 想请问flash高手...这程式哪里出问题?
时间Sun Nov 19 14:28:52 2006
※ 引述《jonathanmeow (喵)》之铭言:
: ※ 引述《aquarianboy (一路好走..)》之铭言:
: : function randRange(min:Number, max:Number):Number {
: : var randomNum:Number;
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^
: 这个地方用var_name:Number的用意是什麽啊??
宣告它是一个Number型态的意思
: 感谢您
: 我也曾经怀疑过random的准确性
: 而将程式中random改成Math.floor((Math.random())*31)+1,
: 其结果相同 会出现同样的问题
: function gcd(int1,int2) {
: a=Math.floor(Math.max(int1,int2));
: b=Math.floor(Math.min(int1,int2));
: while(a%b!=0){
: c=a-Math.floor(a/b)*b;
: a=b;
: b=c;
: }
: return b;
: }
我数学学得不好
不过我总觉得上面这段while loop里的除法+无条件舍去的方式容易出问题
你试试看用下面这个用减法的方式,看看会不会还有类似的问题
function gcd (a, b) {
while (a != b) {
if (a > b) {
a = a - b;
} else {
b = b - a;
}
}
return a;
}
: Math.random()
: 适用版本
: Flash Player 5。在 Flash Player 4 中,
: Math 类别的方法和属性是使用近似值来模拟,
: 正确性可能不如 Flash Player 5 所支援的-非模拟数学函数。
: 用法
: Math.random()
: 参数
: 无
: 传回值
: 一个数字
: 说明
: 方法;传回 n,其中 0 <= n < 1。
: 请参阅
: random
: ******************
: 并没有您所说的范例耶
: 还是我漏了哪些东西没有安装或是没看到呢??版本是2004 mx professtional
: (而更奇怪的是 我记得哪里有看过类似您所提供的randRange函数
: 好像是vb还是php的说明文件??)
: 最後 感谢您的回答....
我的版本是flash8 professional英文版
那段范例是在它的说明范例里贴出来的 :)
--
http://eddiexx.blogspot.com/
http://www.eddie.com.tw/
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 220.135.172.127