From Rob Smart <SMARTROB@uk.ibm.com>

In SL if llAbs() is called with the minimum integer value of -2147483648
it will return that value untouched without error.

this patch replicates the SL functionality.

OpenSim currently throws an overflow exception: number too small under
mono or a "System.OverflowException: Negating the minimum value of a
twos complement number is invalid. " under .NET
0.6.3-post-fixes
Sean Dague 2009-02-10 13:36:42 +00:00
parent 180be7de07
commit ac6657d0f1
1 changed files with 5 additions and 1 deletions

View File

@ -361,8 +361,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public LSL_Integer llAbs(int i) public LSL_Integer llAbs(int i)
{ {
// changed to replicate LSL behaviour whereby minimum int value is returned untouched.
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
return (int)Math.Abs(i); if(i == Int32.MinValue)
return i;
else
return (int)Math.Abs(i);
} }
public LSL_Float llFabs(double f) public LSL_Float llFabs(double f)