Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » Elevate Web Builder Technical Support » Support Forums » Elevate Web Builder General » View Thread |
Messages 1 to 7 of 7 total |
Random(0,0) <> 0 |
Tue, Dec 4 2018 1:49 AM | Permanent Link |
Michael Dreher | For all functions calls Random(n,n) I get n for the return value,
except for n=0 where I get numbers > 0. A bug? Using EWB 2.06B15. Michael Dreher |
Tue, Dec 4 2018 3:42 AM | Permanent Link |
Matthew Jones | Michael Dreher wrote:
> For all functions calls Random(n,n) I get n for the return value, > except for n=0 where I get numbers > 0. A bug? Reading the spec, it is as expected. The second param of 0 means between 0 and MaxInt. -- Matthew Jones |
Tue, Dec 4 2018 5:39 AM | Permanent Link |
Michael Dreher | "Matthew Jones" wrote:
// Reading the spec, it is as expected. The second param of 0 means between 0 and MaxInt. The help declares function Random(AFrom: Integer=0; ATo=<MaxInt>): Integer which means that the 2'nd parameter defaults to MaxInt when it's not provided and not when the 2'nd parameter is provided and of value 0. Michael Dreher |
Tue, Dec 4 2018 6:40 AM | Permanent Link |
Matthew Jones | Michael Dreher wrote:
> The help declares I am indeed very wrong. Apologies. What is interesting though is that my code has quite a few calls to Random like: 'RND' + IntToStr(Ceil(Random * 255)) + '-' + IntToStr(Ceil(Random * 255)); Obviously it has multiple modes - and the JavaScript Random is a float returning a number between zero and 1. But the fact that the one you are using is internal means we can't see what is happening. I have to ask though, what are you really expecting to get? Presumably just zero? And what are you actually getting - what range is returned? -- Matthew Jones |
Tue, Dec 4 2018 7:27 AM | Permanent Link |
Michael Dreher | "Matthew Jones" wrote:
// I have to ask though, what are you really expecting to get? // Presumably just zero? And what are you actually getting - what range is returned? Yes zero of course. My application is indexing an array randomly if stringList.Count() > 0 then stringList[Random(0, stringList.Count() - 1)] := '..'; which results in "List index 54653645345 out out of bounds" (the high number differ each run), when stringList.Count() = 1, which means Random(0,0). Michael Dreher |
Tue, Dec 4 2018 9:18 AM | Permanent Link |
Raul Team Elevate | On 12/4/2018 5:39 AM, Michael Dreher wrote:
> which means that the 2'nd parameter defaults to MaxInt when > it's not provided and not when the 2'nd parameter is provided > and of value 0. If step with debugger into random then yes second param is checked for 0 and only then defaulted to maxint (or 9007199254740991). Tim would need to take a look at this one Raul |
Tue, Dec 4 2018 2:04 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Michael,
<< For all functions calls Random(n,n) I get n for the return value, except for n=0 where I get numbers > 0. A bug? Using EWB 2.06B15. >> I've fixed this for 2.06 B19. Tim Young Elevate Software www.elevatesoft.com |
This web page was last updated on Thursday, December 12, 2024 at 08:07 PM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |