UInt16Ops

Namespace: IronPython
We found 10 examples in language CSharp for this search. You will see 36 fragments of code.
        public static DynamicType MakeDynamicType() {
            if (UInt16Type == null) {
                OpsReflectedType ort = new OpsReflectedType("UInt16", typeof(UInt16), typeof(UInt16Ops), null);
                if (Interlocked.CompareExchange<ReflectedType>(ref UInt16Type, ort, null) == null) {
                    return ort;
                }
            }
            return UInt16Type;
        }

        public static DynamicType MakeDynamicType() {
            if (UInt16Type == null) {
                OpsReflectedType ort = new OpsReflectedType("UInt16", typeof(UInt16), typeof(UInt16Ops), null);
                if (Interlocked.CompareExchange<ReflectedType>(ref UInt16Type, ort, null) == null) {
                    return ort;
                }
            }
            return UInt16Type;
        }

//-------------------------------------------------------------------------------------------
// MetaCore
// Author: Chris Moore, [email protected]
// License: MIT
//-------------------------------------------------------------------------------------------
namespace Meta.Core.Operators
{
    using System;
    using System.Linq;
    using System.Linq.Expressions;

    using static FuncExpression;

    public class UInt16Ops
    {
        public static Expression<Func<ushort, ushort>> Abs
            => make((ushort x) => x);

        public static Expression<Func<ushort, ushort, ushort>> Add
            => make<ushort>((x, y) => (ushort)(x + y));

        public static Expression<Func<ushort, ushort, ushort>> Mul
            => make<ushort>((x, y) => (ushort)(x * y));

        public static Expression<Func<ushort, ushort, ushort>> Sub
            => make<ushort>((x, y) => (ushort)(x - y));

        public static Expression<Func<ushort, ushort>> Inc
            => make((ushort x) => ++x);

        public static Expression<Func<ushort, ushort>> Dec
            => make((ushort x) => --x);

        public static Expression<Func<ushort, ushort, bool>> LT
            => make((ushort x, ushort y) => x < y);

        public static Expression<Func<ushort, ushort, bool>> LTEQ
            => make((ushort x, ushort y) => x <= y);

        public static Expression<Func<ushort, ushort, bool>> GT
            => make((ushort x, ushort y) => x > y);

        public static Expression<Func<ushort, ushort, bool>> GTEQ
            => make((ushort x, ushort y) => x >= y);

    }
}


        static Func<T, T, T> Construct()
        {

            switch (typecode<T>())
            {

                case TypeCode.Byte:
                    return cast<Func<T, T, T>>(ByteOps.Sub.Compile());
                case TypeCode.SByte:
                    return cast<Func<T, T, T>>(SByteOps.Sub.Compile());
                case TypeCode.UInt16:
                    return cast<Func<T, T, T>>(UInt16Ops.Sub.Compile());
                default:
                    return lambda<T, T, T>(Expression.Subtract).Compile();

            }
        }

        public static T Apply(T x, T y)
            => _OP(x, y);

        public static T Apply(T x, T y)
            => _OP(x, y);


        static Option<Func<T, T, T>> TryConstruct()
            => Try(() =>
            {
                switch (typecode<T>())
                {

                    case TypeCode.String:
                        return funcx(method<T, T, T>(nameof(String.Concat)).Require().Func<T, T, T>()).Compile();
                    case TypeCode.Byte:
                        return cast<Func<T, T, T>>(ByteOps.Add.Compile());
                    case TypeCode.SByte:
                        return cast<Func<T, T, T>>(SByteOps.Add.Compile());
                    case TypeCode.UInt16:
                        return cast<Func<T, T, T>>(UInt16Ops.Add.Compile());
                    default:
                        return lambda<T, T, T>(Expression.Add).Compile();
                }
            });

        public static T Apply(T x, T y)
            => _OP(x, y);

        public static T Apply(T x, T y)
            => _OP(x, y);



        static Func<T, T, T> Construct()
        {

            switch (typecode<T>())
            {

                case TypeCode.String:
                    return funcx(method<T, T, T>(nameof(String.Concat)).Require().Func<T, T, T>()).Compile();
                case TypeCode.Byte:
                    return cast<Func<T, T, T>>(ByteOps.Mul.Compile());
                case TypeCode.SByte:
                    return cast<Func<T, T, T>>(SByteOps.Mul.Compile());
                case TypeCode.UInt16:
                    return cast<Func<T, T, T>>(UInt16Ops.Mul.Compile());
                default:
                    return lambda<T, T, T>(Expression.Multiply).Compile();

            }
        }

        public static T Apply(T x, T y)
            => _OP(x, y);

        public static T Apply(T x, T y)
            => _OP(x, y);

        #region Unary operators

        [PythonName("__abs__")]
        public static object Abs(object value) {
            Debug.Assert(value is UInt16);
            return value;
        }

        [PythonName("__neg__")]
        public static object Negate(object value) {
            Debug.Assert(value is UInt16);
            return -(Int32)(UInt16)value;
        }

        [PythonName("__pos__")]
        public static object Positive(object value) {
            Debug.Assert(value is UInt16);
            return value;
        }

        [PythonName("__invert__")]
        public static object Invert(object value) {
            Debug.Assert(value is UInt16);
            return ~(UInt16)value;
        }

        #endregion

        internal static object LeftShiftImpl(UInt16 left, UInt16 right) {
            // UInt16 fits into Int32
            return IntOps.LeftShift((int)left, (int)right);
        }
        internal static object PowerImpl(UInt16 left, UInt16 right) {
            // UInt16 fits into Int32
            return IntOps.Power((int)left, (int)right);
        }

        public static DynamicType MakeDynamicType() {
            if (ByteType == null) {
                OpsReflectedType ort = new OpsReflectedType("Byte", typeof(Byte), typeof(ByteOps), null);
                if (Interlocked.CompareExchange<ReflectedType>(ref ByteType, ort, null) == null) {
                    return ort;
                }
            }
            return ByteType;
        }

        [PythonName("__new__")]
        public static object Make(DynamicType cls) {
            return Make(cls, default(Byte));
        }

        [PythonName("__new__")]
        public static object Make(DynamicType cls, object value) {
            if (cls != ByteType) {
                throw Ops.TypeError("Byte.__new__: first argument must be Byte type.");
            }
            IConvertible valueConvertible;
            if ((valueConvertible = value as IConvertible) != null) {
                switch (valueConvertible.GetTypeCode()) {
                    case TypeCode.Byte: return (Byte)(Byte)value;
                    case TypeCode.SByte: return (Byte)(SByte)value;
                    case TypeCode.Int16: return (Byte)(Int16)value;
                    case TypeCode.UInt16: return (Byte)(UInt16)value;
                    case TypeCode.Int32: return (Byte)(Int32)value;
                    case TypeCode.UInt32: return (Byte)(UInt32)value;
                    case TypeCode.Int64: return (Byte)(Int64)value;
                    case TypeCode.UInt64: return (Byte)(UInt64)value;
                    case TypeCode.Single: return (Byte)(Single)value;
                    case TypeCode.Double: return (Byte)(Double)value;
                }
            }
            if (value is String) {
                return Byte.Parse((String)value);
            } else if (value is BigInteger) {
                return (Byte)(BigInteger)value;
            } else if (value is ExtensibleInt) {
                return (Byte)((ExtensibleInt)value).value;
            } else if (value is ExtensibleLong) {
                return (Byte)((ExtensibleLong)value).Value;
            } else if (value is ExtensibleFloat) {
                return (Byte)((ExtensibleFloat)value).value;
            } else if (value is Enum) {
                return Converter.CastEnumToByte(value);
            }
            throw Ops.ValueError("invalid value for Byte.__new__");
        }

        [PythonName("__add__")]
        public static object Add(object left, object right) {
            if (!(left is Byte)) {
                throw Ops.TypeError("'__add__' requires Byte, but received {0}", Ops.GetDynamicType(left).__name__);
            }
            Byte leftByte = (Byte)left;
            IConvertible rightConvertible;
            if ((rightConvertible = right as IConvertible) != null) {
                switch (rightConvertible.GetTypeCode()) {
                    case TypeCode.Boolean: {
                            Int16 result = (Int16)(((Int16)leftByte) + ((Int16)((Boolean)right ? (Byte)1 : (Byte)0)));
                            if (Byte.MinValue <= result && result <= Byte.MaxValue) {
                                return (Byte)result;
                            } else return result;
                        }
                    case TypeCode.Byte: {
                            Int16 result = (Int16)(((Int16)leftByte) + ((Int16)(Byte)right));
                            if (Byte.MinValue <= result && result <= Byte.MaxValue) {
                                return (Byte)result;
                            } else return result;
                        }
                    case TypeCode.SByte: {
                            Int16 result = (Int16)(((Int16)leftByte) + ((Int16)(SByte)right));
                            if (Byte.MinValue <= result && result <= Byte.MaxValue) {
                                return (Byte)result;
                            } else return result;
                        }
                    case TypeCode.Int16: {
                            Int32 result = (Int32)(((Int32)leftByte) + ((Int32)(Int16)right));
                            if (Int16.MinValue <= result && result <= Int16.MaxValue) {
                                return (Int16)result;
                            } else return result;
                        }
                    case TypeCode.UInt16: {
                            Int32 result = (Int32)(((Int32)leftByte) + ((Int32)(UInt16)right));
                            if (UInt16.MinValue <= result && result <= UInt16.MaxValue) {
                                return (UInt16)result;
                            } else return result;
                        }
                    case TypeCode.Int32: {
                            Int64 result = (Int64)(((Int64)leftByte) + ((Int64)(Int32)right));
                            if (Int32.MinValue <= result && result <= Int32.MaxValue) {
                                return (Int32)result;
                            } else return result;
                        }
                    case TypeCode.UInt32: {
                            Int64 result = (Int64)(((Int64)leftByte) + ((Int64)(UInt32)right));
                            if (UInt32.MinValue <= result && result <= UInt32.MaxValue) {
                                return (UInt32)result;
                            } else return result;
                        }
                    case TypeCode.Int64: {
                            return Int64Ops.Add(leftByte, (Int64)right);
                        }
                    case TypeCode.UInt64: {
                            return UInt64Ops.AddImpl(leftByte, (UInt64)right);
                        }
                    case TypeCode.Single: {
                            return SingleOps.AddImpl((Single)leftByte, (Single)(Single)right);
                        }
                    case TypeCode.Double: {
                            return FloatOps.Add((Double)leftByte, (Double)(Double)right);
                        }
                }
            }
            if (right is BigInteger) {
                return LongOps.Add(leftByte, (BigInteger)right);
            } else if (right is Complex64) {
                return ComplexOps.Add(leftByte, (Complex64)right);
            } else if (right is ExtensibleInt) {
                Int64 result = (Int64)(((Int64)leftByte) + ((Int64)((ExtensibleInt)right).value));
                if (Int32.MinValue <= result && result <= Int32.MaxValue) {
                    return (Int32)result;
                } else return result;
            } else if (right is ExtensibleLong) {
                return LongOps.Add(leftByte, ((ExtensibleLong)right).Value);
            } else if (right is ExtensibleFloat) {
                return FloatOps.Add((Double)leftByte, (Double)((ExtensibleFloat)right).value);
            } else if (right is ExtensibleComplex) {
                return ComplexOps.Add(leftByte, ((ExtensibleComplex)right).value);
            }
            return Ops.NotImplemented;
        }
        [PythonName("__div__")]
        public static object Divide(object left, object right) {
            if (!(left is Byte)) {
                throw Ops.TypeError("'__div__' requires Byte, but received {0}", Ops.GetDynamicType(left).__name__);
            }
            Byte leftByte = (Byte)left;
            IConvertible rightConvertible;
            if ((rightConvertible = right as IConvertible) != null) {
                switch (rightConvertible.GetTypeCode()) {
                    case TypeCode.Boolean: {
                            return ByteOps.DivideImpl((Byte)leftByte, (Byte)((Boolean)right ? (Byte)1 : (Byte)0));
                        }
                    case TypeCode.Byte: {
                            return ByteOps.DivideImpl((Byte)leftByte, (Byte)(Byte)right);
                        }
                    case TypeCode.SByte: {
                            return Int16Ops.DivideImpl((Int16)leftByte, (Int16)(SByte)right);
                        }
                    case TypeCode.Int16: {
                            return Int16Ops.DivideImpl((Int16)leftByte, (Int16)(Int16)right);
                        }
                    case TypeCode.UInt16: {
                            return UInt16Ops.DivideImpl((UInt16)leftByte, (UInt16)(UInt16)right);
                        }
                    case TypeCode.Int32: {
                            return IntOps.Divide((Int32)leftByte, (Int32)(Int32)right);
                        }
                    case TypeCode.UInt32: {
                            return UInt32Ops.DivideImpl((UInt32)leftByte, (UInt32)(UInt32)right);
                        }
                    case TypeCode.Int64: {
                            return Int64Ops.Divide((Int64)leftByte, (Int64)(Int64)right);
                        }
                    case TypeCode.UInt64: {
                            return UInt64Ops.DivideImpl((UInt64)leftByte, (UInt64)(UInt64)right);
                        }
                    case TypeCode.Single: {
                            return SingleOps.DivideImpl((Single)leftByte, (Single)(Single)right);
                        }
                    case TypeCode.Double: {
                            return FloatOps.Divide((Double)leftByte, (Double)(Double)right);
                        }
                }
            }
            if (right is BigInteger) {
                return LongOps.Divide(leftByte, (BigInteger)right);
            } else if (right is Complex64) {
                return ComplexOps.Divide(leftByte, (Complex64)right);
            } else if (right is ExtensibleInt) {
                return IntOps.Divide((Int32)leftByte, (Int32)((ExtensibleInt)right).value);
            } else if (right is ExtensibleLong) {
                return LongOps.Divide(leftByte, ((ExtensibleLong)right).Value);
            } else if (right is ExtensibleFloat) {
                return FloatOps.Divide((Double)leftByte, (Double)((ExtensibleFloat)right).value);
            } else if (right is ExtensibleComplex) {
                return ComplexOps.Divide(leftByte, ((ExtensibleComplex)right).value);
            }
            return Ops.NotImplemented;
        }
        [PythonName("__floordiv__")]
        public static object FloorDivide(object left, object right) {
            if (!(left is Byte)) {
                throw Ops.TypeError("'__floordiv__' requires Byte, but received {0}", Ops.GetDynamicType(left).__name__);
            }
            Byte leftByte = (Byte)left;
            IConvertible rightConvertible;
            if ((rightConvertible = right as IConvertible) != null) {
                switch (rightConvertible.GetTypeCode()) {
                    case TypeCode.Boolean: {
                            return ByteOps.FloorDivideImpl((Byte)leftByte, (Byte)((Boolean)right ? (Byte)1 : (Byte)0));
                        }
                    case TypeCode.Byte: {
                            return ByteOps.FloorDivideImpl((Byte)leftByte, (Byte)(Byte)right);
                        }
                    case TypeCode.SByte: {
                            return Int16Ops.FloorDivideImpl((Int16)leftByte, (Int16)(SByte)right);
                        }
                    case TypeCode.Int16: {
                            return Int16Ops.FloorDivideImpl((Int16)leftByte, (Int16)(Int16)right);
                        }
                    case TypeCode.UInt16: {
                            return UInt16Ops.FloorDivideImpl((UInt16)leftByte, (UInt16)(UInt16)right);
                        }
                    case TypeCode.Int32: {
                            return IntOps.FloorDivide((Int32)leftByte, (Int32)(Int32)right);
                        }
                    case TypeCode.UInt32: {
                            return UInt32Ops.FloorDivideImpl((UInt32)leftByte, (UInt32)(UInt32)right);
                        }
                    case TypeCode.Int64: {
                            return Int64Ops.FloorDivide((Int64)leftByte, (Int64)(Int64)right);
                        }
                    case TypeCode.UInt64: {
                            return UInt64Ops.FloorDivideImpl((UInt64)leftByte, (UInt64)(UInt64)right);
                        }
                    case TypeCode.Single: {
                            return SingleOps.FloorDivideImpl((Single)leftByte, (Single)(Single)right);
                        }
                    case TypeCode.Double: {
                            return FloatOps.FloorDivide((Double)leftByte, (Double)(Double)right);
                        }
                }
            }
            if (right is BigInteger) {
                return LongOps.FloorDivide(leftByte, (BigInteger)right);
            } else if (right is Complex64) {
                return ComplexOps.FloorDivide(leftByte, (Complex64)right);
            } else if (right is ExtensibleInt) {
                return IntOps.FloorDivide((Int32)leftByte, (Int32)((ExtensibleInt)right).value);
            } else if (right is ExtensibleLong) {
                return LongOps.FloorDivide(leftByte, ((ExtensibleLong)right).Value);
            } else if (right is ExtensibleFloat) {
                return FloatOps.FloorDivide((Double)leftByte, (Double)((ExtensibleFloat)right).value);
            } else if (right is ExtensibleComplex) {
                return ComplexOps.FloorDivide(leftByte, ((ExtensibleComplex)right).value);
            }
            return Ops.NotImplemented;
        }

        #region Unary operators

        [PythonName("__abs__")]
        public static object Abs(object value) {
            Debug.Assert(value is UInt16);
            return value;
        }

        [PythonName("__neg__")]
        public static object Negate(object value) {
            Debug.Assert(value is UInt16);
            return -(Int32)(UInt16)value;
        }

        [PythonName("__pos__")]
        public static object Positive(object value) {
            Debug.Assert(value is UInt16);
            return value;
        }

        [PythonName("__invert__")]
        public static object Invert(object value) {
            Debug.Assert(value is UInt16);
            return ~(UInt16)value;
        }

        #endregion

        internal static object LeftShiftImpl(UInt16 left, UInt16 right) {
            // UInt16 fits into Int32
            return IntOps.LeftShift((int)left, (int)right);
        }
        internal static object PowerImpl(UInt16 left, UInt16 right) {
            // UInt16 fits into Int32
            return IntOps.Power((int)left, (int)right);
        }

        public static DynamicType MakeDynamicType() {
            if (ByteType == null) {
                OpsReflectedType ort = new OpsReflectedType("Byte", typeof(Byte), typeof(ByteOps), null);
                if (Interlocked.CompareExchange<ReflectedType>(ref ByteType, ort, null) == null) {
                    return ort;
                }
            }
            return ByteType;
        }

        [PythonName("__new__")]
        public static object Make(DynamicType cls) {
            return Make(cls, default(Byte));
        }

        [PythonName("__new__")]
        public static object Make(DynamicType cls, object value) {
            if (cls != ByteType) {
                throw Ops.TypeError("Byte.__new__: first argument must be Byte type.");
            }
            IConvertible valueConvertible;
            if ((valueConvertible = value as IConvertible) != null) {
                switch (valueConvertible.GetTypeCode()) {
                    case TypeCode.Byte: return (Byte)(Byte)value;
                    case TypeCode.SByte: return (Byte)(SByte)value;
                    case TypeCode.Int16: return (Byte)(Int16)value;
                    case TypeCode.UInt16: return (Byte)(UInt16)value;
                    case TypeCode.Int32: return (Byte)(Int32)value;
                    case TypeCode.UInt32: return (Byte)(UInt32)value;
                    case TypeCode.Int64: return (Byte)(Int64)value;
                    case TypeCode.UInt64: return (Byte)(UInt64)value;
                    case TypeCode.Single: return (Byte)(Single)value;
                    case TypeCode.Double: return (Byte)(Double)value;
                }
            }
            if (value is String) {
                return Byte.Parse((String)value);
            } else if (value is BigInteger) {
                return (Byte)(BigInteger)value;
            } else if (value is ExtensibleInt) {
                return (Byte)((ExtensibleInt)value).value;
            } else if (value is ExtensibleLong) {
                return (Byte)((ExtensibleLong)value).Value;
            } else if (value is ExtensibleFloat) {
                return (Byte)((ExtensibleFloat)value).value;
            } else if (value is Enum) {
                return Converter.CastEnumToByte(value);
            }
            throw Ops.ValueError("invalid value for Byte.__new__");
        }

        [PythonName("__add__")]
        public static object Add(object left, object right) {
            if (!(left is Byte)) {
                throw Ops.TypeError("'__add__' requires Byte, but received {0}", Ops.GetDynamicType(left).__name__);
            }
            Byte leftByte = (Byte)left;
            IConvertible rightConvertible;
            if ((rightConvertible = right as IConvertible) != null) {
                switch (rightConvertible.GetTypeCode()) {
                    case TypeCode.Boolean: {
                            Int16 result = (Int16)(((Int16)leftByte) + ((Int16)((Boolean)right ? (Byte)1 : (Byte)0)));
                            if (Byte.MinValue <= result && result <= Byte.MaxValue) {
                                return (Byte)result;
                            } else return result;
                        }
                    case TypeCode.Byte: {
                            Int16 result = (Int16)(((Int16)leftByte) + ((Int16)(Byte)right));
                            if (Byte.MinValue <= result && result <= Byte.MaxValue) {
                                return (Byte)result;
                            } else return result;
                        }
                    case TypeCode.SByte: {
                            Int16 result = (Int16)(((Int16)leftByte) + ((Int16)(SByte)right));
                            if (Byte.MinValue <= result && result <= Byte.MaxValue) {
                                return (Byte)result;
                            } else return result;
                        }
                    case TypeCode.Int16: {
                            Int32 result = (Int32)(((Int32)leftByte) + ((Int32)(Int16)right));
                            if (Int16.MinValue <= result && result <= Int16.MaxValue) {
                                return (Int16)result;
                            } else return result;
                        }
                    case TypeCode.UInt16: {
                            Int32 result = (Int32)(((Int32)leftByte) + ((Int32)(UInt16)right));
                            if (UInt16.MinValue <= result && result <= UInt16.MaxValue) {
                                return (UInt16)result;
                            } else return result;
                        }
                    case TypeCode.Int32: {
                            Int64 result = (Int64)(((Int64)leftByte) + ((Int64)(Int32)right));
                            if (Int32.MinValue <= result && result <= Int32.MaxValue) {
                                return (Int32)result;
                            } else return result;
                        }
                    case TypeCode.UInt32: {
                            Int64 result = (Int64)(((Int64)leftByte) + ((Int64)(UInt32)right));
                            if (UInt32.MinValue <= result && result <= UInt32.MaxValue) {
                                return (UInt32)result;
                            } else return result;
                        }
                    case TypeCode.Int64: {
                            return Int64Ops.Add(leftByte, (Int64)right);
                        }
                    case TypeCode.UInt64: {
                            return UInt64Ops.AddImpl(leftByte, (UInt64)right);
                        }
                    case TypeCode.Single: {
                            return SingleOps.AddImpl((Single)leftByte, (Single)(Single)right);
                        }
                    case TypeCode.Double: {
                            return FloatOps.Add((Double)leftByte, (Double)(Double)right);
                        }
                }
            }
            if (right is BigInteger) {
                return LongOps.Add(leftByte, (BigInteger)right);
            } else if (right is Complex64) {
                return ComplexOps.Add(leftByte, (Complex64)right);
            } else if (right is ExtensibleInt) {
                Int64 result = (Int64)(((Int64)leftByte) + ((Int64)((ExtensibleInt)right).value));
                if (Int32.MinValue <= result && result <= Int32.MaxValue) {
                    return (Int32)result;
                } else return result;
            } else if (right is ExtensibleLong) {
                return LongOps.Add(leftByte, ((ExtensibleLong)right).Value);
            } else if (right is ExtensibleFloat) {
                return FloatOps.Add((Double)leftByte, (Double)((ExtensibleFloat)right).value);
            } else if (right is ExtensibleComplex) {
                return ComplexOps.Add(leftByte, ((ExtensibleComplex)right).value);
            }
            return Ops.NotImplemented;
        }
        [PythonName("__div__")]
        public static object Divide(object left, object right) {
            if (!(left is Byte)) {
                throw Ops.TypeError("'__div__' requires Byte, but received {0}", Ops.GetDynamicType(left).__name__);
            }
            Byte leftByte = (Byte)left;
            IConvertible rightConvertible;
            if ((rightConvertible = right as IConvertible) != null) {
                switch (rightConvertible.GetTypeCode()) {
                    case TypeCode.Boolean: {
                            return ByteOps.DivideImpl((Byte)leftByte, (Byte)((Boolean)right ? (Byte)1 : (Byte)0));
                        }
                    case TypeCode.Byte: {
                            return ByteOps.DivideImpl((Byte)leftByte, (Byte)(Byte)right);
                        }
                    case TypeCode.SByte: {
                            return Int16Ops.DivideImpl((Int16)leftByte, (Int16)(SByte)right);
                        }
                    case TypeCode.Int16: {
                            return Int16Ops.DivideImpl((Int16)leftByte, (Int16)(Int16)right);
                        }
                    case TypeCode.UInt16: {
                            return UInt16Ops.DivideImpl((UInt16)leftByte, (UInt16)(UInt16)right);
                        }
                    case TypeCode.Int32: {
                            return IntOps.Divide((Int32)leftByte, (Int32)(Int32)right);
                        }
                    case TypeCode.UInt32: {
                            return UInt32Ops.DivideImpl((UInt32)leftByte, (UInt32)(UInt32)right);
                        }
                    case TypeCode.Int64: {
                            return Int64Ops.Divide((Int64)leftByte, (Int64)(Int64)right);
                        }
                    case TypeCode.UInt64: {
                            return UInt64Ops.DivideImpl((UInt64)leftByte, (UInt64)(UInt64)right);
                        }
                    case TypeCode.Single: {
                            return SingleOps.DivideImpl((Single)leftByte, (Single)(Single)right);
                        }
                    case TypeCode.Double: {
                            return FloatOps.Divide((Double)leftByte, (Double)(Double)right);
                        }
                }
            }
            if (right is BigInteger) {
                return LongOps.Divide(leftByte, (BigInteger)right);
            } else if (right is Complex64) {
                return ComplexOps.Divide(leftByte, (Complex64)right);
            } else if (right is ExtensibleInt) {
                return IntOps.Divide((Int32)leftByte, (Int32)((ExtensibleInt)right).value);
            } else if (right is ExtensibleLong) {
                return LongOps.Divide(leftByte, ((ExtensibleLong)right).Value);
            } else if (right is ExtensibleFloat) {
                return FloatOps.Divide((Double)leftByte, (Double)((ExtensibleFloat)right).value);
            } else if (right is ExtensibleComplex) {
                return ComplexOps.Divide(leftByte, ((ExtensibleComplex)right).value);
            }
            return Ops.NotImplemented;
        }
        [PythonName("__floordiv__")]
        public static object FloorDivide(object left, object right) {
            if (!(left is Byte)) {
                throw Ops.TypeError("'__floordiv__' requires Byte, but received {0}", Ops.GetDynamicType(left).__name__);
            }
            Byte leftByte = (Byte)left;
            IConvertible rightConvertible;
            if ((rightConvertible = right as IConvertible) != null) {
                switch (rightConvertible.GetTypeCode()) {
                    case TypeCode.Boolean: {
                            return ByteOps.FloorDivideImpl((Byte)leftByte, (Byte)((Boolean)right ? (Byte)1 : (Byte)0));
                        }
                    case TypeCode.Byte: {
                            return ByteOps.FloorDivideImpl((Byte)leftByte, (Byte)(Byte)right);
                        }
                    case TypeCode.SByte: {
                            return Int16Ops.FloorDivideImpl((Int16)leftByte, (Int16)(SByte)right);
                        }
                    case TypeCode.Int16: {
                            return Int16Ops.FloorDivideImpl((Int16)leftByte, (Int16)(Int16)right);
                        }
                    case TypeCode.UInt16: {
                            return UInt16Ops.FloorDivideImpl((UInt16)leftByte, (UInt16)(UInt16)right);
                        }
                    case TypeCode.Int32: {
                            return IntOps.FloorDivide((Int32)leftByte, (Int32)(Int32)right);
                        }
                    case TypeCode.UInt32: {
                            return UInt32Ops.FloorDivideImpl((UInt32)leftByte, (UInt32)(UInt32)right);
                        }
                    case TypeCode.Int64: {
                            return Int64Ops.FloorDivide((Int64)leftByte, (Int64)(Int64)right);
                        }
                    case TypeCode.UInt64: {
                            return UInt64Ops.FloorDivideImpl((UInt64)leftByte, (UInt64)(UInt64)right);
                        }
                    case TypeCode.Single: {
                            return SingleOps.FloorDivideImpl((Single)leftByte, (Single)(Single)right);
                        }
                    case TypeCode.Double: {
                            return FloatOps.FloorDivide((Double)leftByte, (Double)(Double)right);
                        }
                }
            }
            if (right is BigInteger) {
                return LongOps.FloorDivide(leftByte, (BigInteger)right);
            } else if (right is Complex64) {
                return ComplexOps.FloorDivide(leftByte, (Complex64)right);
            } else if (right is ExtensibleInt) {
                return IntOps.FloorDivide((Int32)leftByte, (Int32)((ExtensibleInt)right).value);
            } else if (right is ExtensibleLong) {
                return LongOps.FloorDivide(leftByte, ((ExtensibleLong)right).Value);
            } else if (right is ExtensibleFloat) {
                return FloatOps.FloorDivide((Double)leftByte, (Double)((ExtensibleFloat)right).value);
            } else if (right is ExtensibleComplex) {
                return ComplexOps.FloorDivide(leftByte, ((ExtensibleComplex)right).value);
            }
            return Ops.NotImplemented;
        }