Announcement

Collapse
No announcement yet.

Math.Random return -2147483648

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Math.Random return -2147483648

    Hi all,
    I'm trying to use 'Math.Random' action to generate 10 digit random number but it returned -2147483648.

    I think the digits of generated number in 'Math.Random' action is limited.
    Is there anyone to help me for solving this problem?

  • #2
    Unless you use external libraries, you may see this happening, as the big number causes an overflow. However, you could easily write your own random number generator, if you really need big numbers, for example:
    Code:
    function Math.BigRandom()
    	local nRand1 = Math.Random(0, 99999);
    	local nRand2 = Math.Random(0, 99999);
    	return string.format("%05d%05d", nRand1, nRand2);
    end
    Ulrich

    Comment


    • #3
      Originally posted by Ulrich View Post
      Unless you use external libraries, you may see this happening, as the big number causes an overflow. However, you could easily write your own random number generator, if you really need big numbers, for example:
      Code:
      function Math.BigRandom()
      	local nRand1 = Math.Random(0, 99999);
      	local nRand2 = Math.Random(0, 99999);
      	return string.format("%05d%05d", nRand1, nRand2);
      end
      Ulrich
      Thanks Ulrich,
      Can you give me more information about string.format? I can't find it in Action Wizard...

      Comment


      • #4
        Please refer to the Lua 5.1 Reference Manual for details on standard Lua functions defined in the language.

        Ulrich

        Comment


        • #5
          Originally posted by Ulrich View Post
          Please refer to the Lua 5.1 Reference Manual for details on standard Lua functions defined in the language.

          Ulrich
          Thanks Again For Your Reply...
          I suggest use all of the LUA functions and modules in next version of AMS (in Action Wizard) or put a description in AMS help file.

          Comment


          • #6
            Originally posted by mslight13 View Post
            Thanks Again For Your Reply...
            I suggest use all of the LUA functions and modules in next version of AMS (in Action Wizard) or put a description in AMS help file.
            Indigorose is not responsible for documenting Lua functions. Lua is a standalone scripting engine which is used in AMS, you can read up on all the Lua 5.1 functions in the Lua 5.1 reference manual.
            Bas Groothedde
            Imagine Programming :: Blog

            AMS8 Plugins
            IMXLH Compiler

            Comment

            Working...
            X