[Opensim-users] Simple lsl bug with dramatic effect
Justin Clark-Casey
jjustincc at googlemail.com
Wed May 8 22:11:33 UTC 2013
I believe integer is a 32-bit signed integer. Your first example ends up causing integer overflow.
I was curious so I googled [1]. You'll see somewhat curious behavior in the LL grid as well in those situations, though
I think the curious behaviour will be different from our curious behaviour.
[1] http://wiki.secondlife.com/wiki/LSL_101/LSL_in_Focus:_Integers#Integer_Overflow
On 08/05/13 15:16, Dr Ramesh Ramloll wrote:
> Hello,
> I am sharing on this list hoping that some brains could help me figure this one out. I think I have hit a modulus
> divisor bug. Please let me know what you think. This had a significant impact on my scripts ... the whole thing froze
> after I made a simple change to a single variable and am wondering if I have hit some constraints that I am not aware
> of. Basically I am trying to pass parameters to a rezzed child object (see below). I generate values at the parent prim
> and try to get those values back from the rezzed child. Any thoughts appreciated.
> Thank you.
>
> integer commChannel =54;
> integer modulus_divisor = 1000000000;
> integer objectPinIndex = 23;
> integer rezParameter;
> integer repro_commChannel;
> integer repro_objectPinIndex;
>
> default
> {
> state_entry()
> {
> rezParameter = -1*((commChannel*modulus_divisor)+(objectPinIndex));
> repro_commChannel = -1*((integer)rezParameter)/modulus_divisor;
> repro_objectPinIndex = -1*((integer)rezParameter)%modulus_divisor;
> llOwnerSay("modulus="+(string)modulus_divisor);
> llOwnerSay("objectPinIndex="+(string)objectPinIndex);
> llOwnerSay("commChannel="+(string)commChannel);
> llOwnerSay("REPRODUCING VALUES");
> llOwnerSay("repro_objectPinIndex="+(string)repro_objectPinIndex);
> llOwnerSay("repro_commChannel="+(string)repro_commChannel);
> }
> }
>
> output follows:
>
> modulus=100000000 (eight zeroes)
> [06:57] Primitive: modulus=100000000
> [06:57] Primitive: objectPinIndex=23
> [06:57] Primitive: commChannel=54
> [06:57] Primitive: REPRODUCING VALUES
> [06:57] Primitive: repro_objectPinIndex=5032727
> [06:57] Primitive: repro_commChannel=11
>
>
>
> now change modulus = 10000000
>
> output is:
>
> Primitive: modulus=10000000 (seven zeroes)
> [06:56] Primitive: objectPinIndex=23
> [06:56] Primitive: commChannel=54
> [06:56] Primitive: REPRODUCING VALUES
> [06:56] Primitive: repro_objectPinIndex=23
> [06:56] Primitive: repro_commChannel=54
>
>
> also, modulus_divisor = 29999999 works
> modulus_divisor = 39699999 also works; this appears to be the experimental upper bound before modulus_divisor stops working.
> I did not expect this.
>
> --
> 'Consider how the lilies grow. They do not labor or spin.'
> *Rameshsharma Ramloll* PhD, CEO CTO DeepSemaphore LLC, Affiliate /Research Associate Professor/, Idaho State University,
> Pocatello, ID 83209 Tel: 208-240-0040
> Blog <http://deepsemaphore.posterous.com/>, LinkedIn <http://www.linkedin.com/in/rameshramloll>, DeepSemaphore LLC
> <http://www.deepsemaphore.com>, Google+ profile <https://plus.google.com/103652369558830540272/about>
>
>
> _______________________________________________
> Opensim-users mailing list
> Opensim-users at lists.berlios.de
> https://lists.berlios.de/mailman/listinfo/opensim-users
>
--
Justin Clark-Casey (justincc)
OSVW Consulting
http://justincc.org
http://twitter.com/justincc
More information about the Opensim-users
mailing list