tag:blogger.com,1999:blog-5384857.post9020262992421635036..comments2023-10-10T03:52:55.494+01:00Comments on Under The Stairs: Random Numbers in PowerShellUnknownnoreply@blogger.comBlogger5125tag:blogger.com,1999:blog-5384857.post-72332877459535028952013-04-24T21:48:42.007+01:002013-04-24T21:48:42.007+01:00@tim, It is most definitely not a feature.
If you...@tim, It is most definitely not a feature.<br /><br />If you have an array it is indexed 0 to length-1. Using Next you can just call "Next(0, myArray.Length)" and always get a valid index.leftlerhttps://www.blogger.com/profile/01671428489858168893noreply@blogger.comtag:blogger.com,1999:blog-5384857.post-83523825097131429372011-04-10T19:04:21.652+01:002011-04-10T19:04:21.652+01:00Well spotted. The second parameter is exclusive. T...Well spotted. The second parameter is exclusive. To create a random number between 0 and 1, you'd type $r.next(0,2).<br /><br />Thanks for spotting this.Thomas Leehttps://www.blogger.com/profile/05591926562143348089noreply@blogger.comtag:blogger.com,1999:blog-5384857.post-17916095949476486042011-04-10T18:55:52.446+01:002011-04-10T18:55:52.446+01:00You are both correct. The upper bound is actually ...You are both correct. The upper bound is actually exclusive. So to create a number between 1 and ten, you'd use next(1,11). Some may regard this as a bug of the API. For others it's a feature.Unknownhttps://www.blogger.com/profile/11148743713835851601noreply@blogger.comtag:blogger.com,1999:blog-5384857.post-74698440683187360792011-04-08T01:23:53.076+01:002011-04-08T01:23:53.076+01:00check this out
$r.Next(0,1) never generate one it...check this out <br />$r.Next(0,1) never generate one it is always 0 so the upper bound is not inclusive.Unknownhttps://www.blogger.com/profile/00668919205780254648noreply@blogger.comtag:blogger.com,1999:blog-5384857.post-52860520199367022842008-03-19T22:22:00.000+00:002008-03-19T22:22:00.000+00:00This isn't quite correct. To generate a number bet...This isn't quite correct. To generate a number between 4 and 16, you need to use (4,17)Ry Joneshttps://www.blogger.com/profile/06955133968509322767noreply@blogger.com