Like @Bradley, you get an overflow in your overflow check. But the problem is bigger.
Let's look at this line first
if(value + adder > long.MaxValue)
value adder , . , longs , , , , - , , .
, , , multiplyLong. ,
if (value * multiplier > long.MaxValue)
value , multiplier - float, , long, .
, value * multiplier , long.MaxValue long?
, long.MinValue, , , long.MaxValue
, , , .
, ? decimal . -, , long (decimal 79228162514264337593543950335, long 9223372036854775807), , .
,
public static long multiplyLong(decimal value, decimal multiplier)
{
try
{
return value*multiplier;
}
catch (OverflowException e)
{
Debug.Log("greater then max value");
return decimal.MaxValue;
}
}
public static long addLong(decimal value, decimal adder)
{
try
{
return value+adder;
}
catch (OverflowException e)
{
Debug.Log("greater then max value");
return decimal.MaxValue;
}
}