/// <inheritdoc /> protected override object Operate(object lhs, object rhs, ScriptContext context) { object value = lhs; int steps = rhs.Convert <int>(); int numberofbits = value.GetNumberOfBits(this); if (steps >= numberofbits) { return(Activator.CreateInstance(value.GetType())); } object mask = ValueExtensions.GetMask(value.GetType(), numberofbits - steps); return(((dynamic)value >> (dynamic)steps) & (dynamic)mask); }
/// <inheritdoc /> protected override object Operate(object lhs, object rhs, ScriptContext context) { object value = lhs; int steps = Converter.Convert <int>(rhs); int numberofbits = value.GetNumberOfBits(this); steps = steps % numberofbits; if (steps == 0) { return(value); } object mask = ValueExtensions.GetMask(value.GetType(), numberofbits - steps); return((((dynamic)value >> steps) & (dynamic)mask) | ((dynamic)value << (numberofbits - steps))); }