生成随机阳性/阴性号码 [英] Generate random postive/negative Number
本文介绍了生成随机阳性/阴性号码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你如何生成一个数字,随机阳性还是消极的?
How do you generate a Number that is randomly postive or negative?
推荐答案
你提供低和高的数字作为参数,此功能
Provide your low and high numbers as parameters to this function
function randomNumber(low:Number=0, high:Number=1):Number {
return Math.floor(Math.random() * (1+high-low)) + low;
}
这篇关于生成随机阳性/阴性号码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文