Пример #1
0
        public static EcmaValue AsUintN(EcmaValue bits, EcmaValue value)
        {
            long n = bits.ToIndex();

            value = value.ToPrimitive(EcmaPreferredPrimitiveType.Number);
            return(BigIntHelper.ToBigUIntN(value, (int)Math.Min(n, Int32.MaxValue)));
        }
Пример #2
0
        public static EcmaValue ToString([This] EcmaValue thisValue, EcmaValue radix)
        {
            EcmaValue bigInt = thisValue.GetIntrinsicPrimitiveValue(EcmaValueType.BigInt);
            EcmaValue b      = radix == default ? 10 : radix.ToInteger();

            return(BigIntHelper.ToString(bigInt, b.ToInt32()));
        }
Пример #3
0
        public static EcmaValue BigInt(EcmaValue value)
        {
            value = value.ToPrimitive(EcmaPreferredPrimitiveType.Number);
            switch (EcmaValue.GetNumberCoercion(value))
            {
            case EcmaNumberType.BigInt:
            case EcmaNumberType.BigInt64:
                return(value);

            case EcmaNumberType.Double:
                return(BigIntHelper.ToBigInt(value.ToDouble()));

            case EcmaNumberType.Int64:
            case EcmaNumberType.Int32:
                return(BigIntHelper.ToBigInt(value.ToInt64()));
            }
            return(BigIntHelper.ToBigInt(value));
        }