Math_Random not random?

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Math_Random not random?

Steve Linford
Has anyone come across a situation where Math_Random returns the same  
number constantly, in the case below always "2147483647" (Lasso 7.1  
on OSX Server)?

[var:'email_token'=(Math_Random: -Min=1483628394, -Max=9263425389)]
[var: 'email_token']

I'm trying to generate a 10-digit random number...

--
   Steve Linford
   Ultradesign Xtreme Network
   http://www.uxn.com




------------------------------
Lasso Support: http://support.omnipilot.com/
Search the list archives: http://www.listsearch.com/lassotalk.lasso
Manage your list subscription:  
http://www.listsearch.com/lassotalk.lasso?manage
Reply | Threaded
Open this post in threaded view
|

Re: Math_Random not random?

Steve Upton
At 8:02 PM +0200 9/5/06, Steve Linford wrote:
>Has anyone come across a situation where Math_Random returns the same number constantly, in the case below always "2147483647" (Lasso 7.1 on OSX Server)?
>
>[var:'email_token'=(Math_Random: -Min=1483628394, -Max=9263425389)]
>[var: 'email_token']
>
>I'm trying to generate a 10-digit random number...

This looks like you are up against the size of an integer so your token variable can't store the number. I don't have a reference handy but the result starting with 214... reminds me of an upper number limit for integers...

perhaps you should either set your token to a large integer or convert the random result to text prior to storing it in a var...

Regards,

Steve Upton

--


------------------------------
Lasso Support: http://support.omnipilot.com/
Search the list archives: http://www.listsearch.com/lassotalk.lasso
Manage your list subscription:  
http://www.listsearch.com/lassotalk.lasso?manage
Reply | Threaded
Open this post in threaded view
|

Re: Math_Random not random?

Fletcher Sandbeck
On 2006-09-05 at 11:22 by [hidden email] (Steve Upton):

>At 8:02 PM +0200 9/5/06, Steve Linford wrote:
>>Has anyone come across a situation where Math_Random returns the same number constantly, in the case below
>always "2147483647" (Lasso 7.1 on OSX Server)?
>>
>>[var:'email_token'=(Math_Random: -Min=1483628394, -Max=9263425389)]
>>[var: 'email_token']
>>
>>I'm trying to generate a 10-digit random number...
>
>This looks like you are up against the size of an integer so your
>token variable can't store the number. I don't have a reference handy
>but the result starting with 214... reminds me of an upper number
>limit for integers...
>
>perhaps you should either set your token to a large integer or convert the random result to text prior to
>storing it in a var...

2147483647 is the largest 32-bit signed integer and also a prime number! <http://primes.utm.edu/curios/page.php/2147483647.html>

It might be better to create two 5 digit random numbers and concatenate them.

[var: 'email_token' = (string: (math_random: -min=10000, -max=99999)) + (string: (math_random: -min=10000, -max=99999))]

Lasso 8 and higher use 64-bit storage for integers so can handle integers up to 9,223,372,036,854,775,807.  Lasso 8.5 introduces the [BigInt] type that can handle integers of arbitrary length.

[fletcher]
--
Fletcher Sandbeck                         [hidden email]
Director of Product Development       http://www.lassostudio.com
OmniPilot Software, Inc.                http://www.omnipilot.com

------------------------------
Lasso Support: http://support.omnipilot.com/
Search the list archives: http://www.listsearch.com/lassotalk.lasso
Manage your list subscription:  
http://www.listsearch.com/lassotalk.lasso?manage
Reply | Threaded
Open this post in threaded view
|

Re: Math_Random not random?

decorior
Just a thought.

It might be useful also to know the application.

That is certainly a big number, and having that big a random number  
sounds more like random text.

If you are looking for something key based, then a primary key that  
gets encoded with blowfish should get you there.

Deco

On Sep 5, 2006, at 12:34 PM, Fletcher Sandbeck wrote:

> On 2006-09-05 at 11:22 by [hidden email] (Steve Upton):
>
>> At 8:02 PM +0200 9/5/06, Steve Linford wrote:
>>> Has anyone come across a situation where Math_Random returns the  
>>> same number constantly, in the case below
>> always "2147483647" (Lasso 7.1 on OSX Server)?
>>>
>>> [var:'email_token'=(Math_Random: -Min=1483628394, -Max=9263425389)]
>>> [var: 'email_token']
>>>
>>> I'm trying to generate a 10-digit random number...
>>
>> This looks like you are up against the size of an integer so your
>> token variable can't store the number. I don't have a reference handy
>> but the result starting with 214... reminds me of an upper number
>> limit for integers...
>>
>> perhaps you should either set your token to a large integer or  
>> convert the random result to text prior to
>> storing it in a var...
>
> 2147483647 is the largest 32-bit signed integer and also a prime  
> number! <http://primes.utm.edu/curios/page.php/2147483647.html>
>
> It might be better to create two 5 digit random numbers and  
> concatenate them.
>
> [var: 'email_token' = (string: (math_random: -min=10000, -
> max=99999)) + (string: (math_random: -min=10000, -max=99999))]
>
> Lasso 8 and higher use 64-bit storage for integers so can handle  
> integers up to 9,223,372,036,854,775,807.  Lasso 8.5 introduces the  
> [BigInt] type that can handle integers of arbitrary length.
>
> [fletcher]
> --
> Fletcher Sandbeck                         [hidden email]
> Director of Product Development       http://www.lassostudio.com
> OmniPilot Software, Inc.                http://www.omnipilot.com
>
> ------------------------------
> Lasso Support: http://support.omnipilot.com/
> Search the list archives: http://www.listsearch.com/lassotalk.lasso
> Manage your list subscription:
> http://www.listsearch.com/lassotalk.lasso?manage


------------------------------
Lasso Support: http://support.omnipilot.com/
Search the list archives: http://www.listsearch.com/lassotalk.lasso
Manage your list subscription:  
http://www.listsearch.com/lassotalk.lasso?manage
Reply | Threaded
Open this post in threaded view
|

Re: Math_Random not random?

Steve Linford
In reply to this post by Fletcher Sandbeck
On 5 Sep 2006, at 20:34, Fletcher Sandbeck wrote:

> On 2006-09-05 at 11:22 by [hidden email] (Steve Upton):
>
>> At 8:02 PM +0200 9/5/06, Steve Linford wrote:
>>> Has anyone come across a situation where Math_Random returns the  
>>> same number constantly, in the case below
>> always "2147483647" (Lasso 7.1 on OSX Server)?
>>>
>>> [var:'email_token'=(Math_Random: -Min=1483628394, -Max=9263425389)]
>>> [var: 'email_token']
>>>
>>> I'm trying to generate a 10-digit random number...
>>
>> This looks like you are up against the size of an integer so your
>> token variable can't store the number. I don't have a reference handy
>> but the result starting with 214... reminds me of an upper number
>> limit for integers...
>>
>> perhaps you should either set your token to a large integer or  
>> convert the random result to text prior to
>> storing it in a var...
>
> 2147483647 is the largest 32-bit signed integer and also a prime  
> number! <http://primes.utm.edu/curios/page.php/2147483647.html>
>
> It might be better to create two 5 digit random numbers and  
> concatenate them.
>
> [var: 'email_token' = (string: (math_random: -min=10000, -
> max=99999)) + (string: (math_random: -min=10000, -max=99999))]
>
> Lasso 8 and higher use 64-bit storage for integers so can handle  
> integers up to 9,223,372,036,854,775,807.  Lasso 8.5 introduces the  
> [BigInt] type that can handle integers of arbitrary length.

Thanks Fletcher! That fixed it nicely.

--
   Steve Linford
   Ultradesign Xtreme Network
   http://www.uxn.com




------------------------------
Lasso Support: http://support.omnipilot.com/
Search the list archives: http://www.listsearch.com/lassotalk.lasso
Manage your list subscription:  
http://www.listsearch.com/lassotalk.lasso?manage
Reply | Threaded
Open this post in threaded view
|

Re: Math_Random not random?

stevepiercy
On Tuesday, September 5, 2006, [hidden email] (Steve Linford) pronounced:

>> It might be better to create two 5 digit random numbers and  
>> concatenate them.
>>
>> [var: 'email_token' = (string: (math_random: -min=10000, -
>> max=99999)) + (string: (math_random: -min=10000, -max=99999))]
>>
>> Lasso 8 and higher use 64-bit storage for integers so can handle  
>> integers up to 9,223,372,036,854,775,807.  Lasso 8.5 introduces the  
>> [BigInt] type that can handle integers of arbitrary length.
>
>Thanks Fletcher! That fixed it nicely.

That would exclude the range of 10-digit numbers:

#####00000 - #####09999

--steve
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Steve Piercy               Web Site Builder               Soquel, CA
<[hidden email]>                   <http://www.StevePiercy.com>

------------------------------
Lasso Support: http://support.omnipilot.com/
Search the list archives: http://www.listsearch.com/lassotalk.lasso
Manage your list subscription:  
http://www.listsearch.com/lassotalk.lasso?manage
Reply | Threaded
Open this post in threaded view
|

Re: Math_Random not random?

Fletcher Sandbeck
On 2006-09-05 at 13:33 by [hidden email] (Steve Piercy - Web Site Builder):

>On Tuesday, September 5, 2006, [hidden email] (Steve Linford) pronounced:
>
>>> It might be better to create two 5 digit random numbers and  
>>> concatenate them.
>>>
>>> [var: 'email_token' = (string: (math_random: -min=10000, -
>>> max=99999)) + (string: (math_random: -min=10000, -max=99999))]
>>>
>>> Lasso 8 and higher use 64-bit storage for integers so can handle  
>>> integers up to 9,223,372,036,854,775,807.  Lasso 8.5 introduces the  
>>> [BigInt] type that can handle integers of arbitrary length.
>>
>>Thanks Fletcher! That fixed it nicely.
>
>That would exclude the range of 10-digit numbers:
>
>#####00000 - #####09999

It excludes even more than that, but so did the code in the original post.  This would fill out the range.

[var: 'email_token' = (string: (math_random: -min=0, -max=100000)->(setformat: -padding=5, -padchar=0) &) + (string: (math_random: -min=0, -max=100000)->(setformat: -padding=5, -padchar=0) &)]

[fletcher]
--
Fletcher Sandbeck                         [hidden email]
Director of Product Development       http://www.lassostudio.com
OmniPilot Software, Inc.                http://www.omnipilot.com

------------------------------
Lasso Support: http://support.omnipilot.com/
Search the list archives: http://www.listsearch.com/lassotalk.lasso
Manage your list subscription:  
http://www.listsearch.com/lassotalk.lasso?manage
Reply | Threaded
Open this post in threaded view
|

Re: Math_Random not random?

Adam Randall-4
Not to say that Fletcher is wrong...but Fletcher's code will only  
work in 8.x and above. In 7, you'd need to do this:

[var: 'email_token' = string(math_random(-min=0, -max=100000)-
 >setformat(-padding=5, -padchar=0) &) + string(math_random(-min=0, -
max=100000)->setformat(-padding=5, -padchar=0) &)]

Regards,

Adam.


--
Adam Randall <[hidden email]>
Senior Web Architect
Stork Avenue, Inc.
http://www.storkavenue.com/
(800) 861-5437
AIM/iChat: blitz574

Mrs. Wormwood: "Calvin, can you tell us what Lewis and Clark did?"
Calvin: "No, but I can recite the secret superhero origin of each  
member of Captain Napalm's Thermonuclear League of Liberty."
Mrs. Wormwood: "See me after class, Calvin."
Calvin: (speaking in retrospect) "I'm not dumb. I just have a command  
of thoroughly useless information."



On Sep 5, 2006, at 4:46 PM, Fletcher Sandbeck wrote:

> On 2006-09-05 at 13:33 by [hidden email] (Steve Piercy - Web  
> Site Builder):
>
>> On Tuesday, September 5, 2006, [hidden email] (Steve Linford)  
>> pronounced:
>>
>>>> It might be better to create two 5 digit random numbers and
>>>> concatenate them.
>>>>
>>>> [var: 'email_token' = (string: (math_random: -min=10000, -
>>>> max=99999)) + (string: (math_random: -min=10000, -max=99999))]
>>>>
>>>> Lasso 8 and higher use 64-bit storage for integers so can handle
>>>> integers up to 9,223,372,036,854,775,807.  Lasso 8.5 introduces the
>>>> [BigInt] type that can handle integers of arbitrary length.
>>>
>>> Thanks Fletcher! That fixed it nicely.
>>
>> That would exclude the range of 10-digit numbers:
>>
>> #####00000 - #####09999
>
> It excludes even more than that, but so did the code in the  
> original post.  This would fill out the range.
>
> [var: 'email_token' = (string: (math_random: -min=0, -max=100000)->
> (setformat: -padding=5, -padchar=0) &) + (string: (math_random: -
> min=0, -max=100000)->(setformat: -padding=5, -padchar=0) &)]
>
> [fletcher]
> --
> Fletcher Sandbeck                         [hidden email]
> Director of Product Development       http://www.lassostudio.com
> OmniPilot Software, Inc.                http://www.omnipilot.com
>
> ------------------------------
> Lasso Support: http://support.omnipilot.com/
> Search the list archives: http://www.listsearch.com/lassotalk.lasso
> Manage your list subscription:
> http://www.listsearch.com/lassotalk.lasso?manage


------------------------------
Lasso Support: http://support.omnipilot.com/
Search the list archives: http://www.listsearch.com/lassotalk.lasso
Manage your list subscription:  
http://www.listsearch.com/lassotalk.lasso?manage