Topic: 请教产生随机数的范围? |
Print this page |
1.请教产生随机数的范围? | Copy to clipboard |
Posted by: soskitty Posted on: 2005-05-31 21:18 书上说 Math.random()方法产生“介于”0与1之间的随机数,请问包不包括1? 拿例子来说就是:(int)(Math.random()*20)有没有可能产生20? 顺便问一下我想自己测试的话该怎么测试? 谢谢! |
2.Re:请教产生随机数的范围? [Re: soskitty] | Copy to clipboard |
Posted by: why Posted on: 2005-05-31 21:35 http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Math.html#random() Returns a double value with a positive sign, greater than or equal to 0.0 and less than 1.0. What do you wnat to 自己测试? |
3.Re:请教产生随机数的范围? [Re: soskitty] | Copy to clipboard |
Posted by: soskitty Posted on: 2005-06-01 09:32 谢谢元老!! |
4.Re:请教产生随机数的范围? [Re: soskitty] | Copy to clipboard |
Posted by: yinpeng263 Posted on: 2005-06-08 03:59 demo code http://www.java2s.com/ExampleCode/Development-Class/Random.htm |
Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1 客服电话 18559299278 客服信箱 714923@qq.com 客服QQ 714923 |