# Welcome!

By registering with us, you'll be able to discuss, share and exchange private messages with other members of our community.

# An undocumented limitation and an associated minor bug...

#### mathewsdw

The following command:

For /L %E in (33,-1,30) Do (Echo %E %@Random[0,%@Eval[2**%E-1]])

and its output:

TCC: (Sys) The parameter is incorrect.
"%@Random[0,8589934591]"
TCC: (Sys) The parameter is incorrect.
"%@Random[0,4294967295]"
31 792146758
30 485602801

would seem to indicate that 2**31-1 is the largest value that the @Random function can take as a parameter, which isn't, as far as I can tell, documented.

However, the very similar command:

For /L %E in (33,-1,30) Do (Echo %E %@Random[0,%@Eval[2**%E]])

produces:

33 0
32 0
TCC: (Sys) The parameter is incorrect.
"%@Random[0,2147483648]"
30 704183992

I tend to think that this is, as it says in the subject line, a relatively minor bug given the above...

The following command:

For /L %E in (33,-1,30) Do (Echo %E %@Random[0,%@Eval[2**%E-1]])

and its output:

TCC: (Sys) The parameter is incorrect.
"%@Random[0,8589934591]"
TCC: (Sys) The parameter is incorrect.
"%@Random[0,4294967295]"
31 792146758
30 485602801

would seem to indicate that 2**31-1 is the largest value that the @Random function can take as a parameter, which isn't, as far as I can tell, documented.

The documentation for 12.10.66 says:

@RANDOM[min, max]: Returns a pseudo random integer value between min and max, inclusive. The random number generator is initialized from the system clock the first time it is used after TCC starts and will therefore produce a different sequence of numbers each time you use it. Min and max are 32-bit signed integers, so the allowable range is -2,147,483,647 to 2,147,483,647.

However, the very similar command:

For /L %E in (33,-1,30) Do (Echo %E %@Random[0,%@Eval[2**%E]])

produces:

33 0
32 0
TCC: (Sys) The parameter is incorrect.
"%@Random[0,2147483648]"
30 704183992

I tend to think that this is, as it says in the subject line, a relatively minor bug given the above...

WAD -- @RANDOM is truncating the argument passed to it, as there is no way it can tell that it's an invalid size. (Unless @RANDOM supported > 32-bit arguments just so it could say that it didn't support > 32-bit arguments, which seems kinda pointless.)

Replies
6
Views
2K
Replies
59
Views
8K
Replies
0
Views
2K
Replies
12
Views
3K
Replies
4
Views
3K
Replies
30
Views
7K