Basic4ppc - Windows Mobile Development  

Go Back   Basic4ppc - Windows Mobile Development > Main Category > Questions & Help Needed
Home Register FAQ Members List Search Today's Posts Mark Forums Read

Questions & Help Needed Post any question regarding Basic4ppc.


Rnd() ignores the maximum value


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-13-2007, 07:36 AM
Junior Member
 
Join Date: Oct 2007
Posts: 25
Default Rnd() ignores the maximum value

If you run this example you'll see that rnd() never returns 1.

Sub App_Start
x=0
Do
n=Rnd(0,1)
If n=0 Then
Msgbox(n)
Else
Msgbox(n)
End If
Loop Until x=1
End Sub
Reply With Quote
  #2 (permalink)  
Old 10-13-2007, 07:40 AM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 3,134
Default

Please read the manual or at least ask in the questions section before posting bug reports: http://www.basic4ppc.com/help/rnd.html
Reply With Quote
  #3 (permalink)  
Old 10-13-2007, 07:45 AM
Junior Member
 
Join Date: Oct 2007
Posts: 25
Default

Sorry. I admit that I skimmed over the documentation for rnd() (as short as it was). I've never seen a rnd function that ignores the upper limit before and assumed wrong. I was convinced this was a bug.

Reply With Quote
  #4 (permalink)  
Old 10-13-2007, 07:48 AM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 3,134
Default

No problem
This is how it behaves in C# and VB .Net.
Reply With Quote
  #5 (permalink)  
Old 10-13-2007, 07:57 AM
Junior Member
 
Join Date: Oct 2007
Posts: 25
Default

Really? That's so confusing. o.o
Reply With Quote
  #6 (permalink)  
Old 10-14-2007, 10:57 PM
Cableguy's Avatar
Basic4ppc Expert
 
Join Date: Apr 2007
Location: N 41º11'30.30" W 8º39'46.60"
Posts: 1,314
Default

In the old days, in my zx spectrum ++, rnd only returned a value between 0 and....1, except for the ....1 so we ould get decimal of 0.1,0.2,....etc and we couldnt even state the max or min values.... now that was confusing....
__________________
Paulo Gomes
Porto, Portugal

PC: Dual-Core 1,8Ghz, 2GB RAM, 80GB HD
PPC: Qtek9000, 1GB SD

DLL Version Listing

Last edited by Cableguy : 10-14-2007 at 11:00 PM.
Reply With Quote
  #7 (permalink)  
Old 10-15-2007, 04:15 PM
specci48's Avatar
Basic4ppc Expert
 
Join Date: Apr 2007
Location: Germany
Posts: 638
Default

Quote:
Originally Posted by Cableguy View Post
In the old days, in my zx spectrum ++, rnd only returned a value between 0 and....1, except for the ....1 so we ould get decimal of 0.1,0.2,....etc and we couldnt even state the max or min values.... now that was confusing....
... max values were possible ...

10 LET A = INT(RND*N)

... results for A are values from 0 to N-1 ...

specci48
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Scrollbar.LargeChange and Maximum BjornF Questions & Help Needed 5 09-29-2008 08:06 PM
HTTP maximum request size and method problems willisgt Questions & Help Needed 1 08-27-2007 08:10 PM


All times are GMT. The time now is 05:28 PM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.1.0