Download the free trial version
Basic4android Video
Features
Tutorials and manuals
Showcase
Screenshots

Go Back   Android Development Forum - Basic4android > Basic4ppc (Windows Mobile) > Questions (Windows Mobile)
Documentation Wiki Register Members List B4P Search Today's Posts Mark Forums Read

Questions (Windows Mobile) 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: 13,162
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
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: 13,162
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
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: 2,313
Awards Showcase
Forum Contributer 
Total Awards: 1
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 - Living/Working in France-Saumur
Mobile Device: Samsung Galaxy S, Android 2.3.4 CUstom ROM
Laptop: Toshiba NB100-130 (running on Win7Ultimate)
B4PPC DLL Version Listing - B4Android 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: 993
Awards Showcase
Beta Tester Forum Contributer 
Total Awards: 2
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 Off
Pingbacks are Off
Refbacks are On

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


All times are GMT. The time now is 03:03 AM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0