1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

An undocumented limitation and an associated minor bug...

Discussion in 'Support' started by mathewsdw, May 16, 2011.

  1. mathewsdw

    May 24, 2010
    Likes Received:
    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.
    TCC: (Sys) The parameter is incorrect.
    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]])


    33 0
    32 0
    TCC: (Sys) The parameter is incorrect.
    30 704183992

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

    rconn Administrator
    Staff Member

    May 14, 2008
    Likes Received:
    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.

    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.)

Share This Page