Beispiel #1
0
        public static BigRational FractionToDouble(UnicodeStream stream, UInt64 decPt)
        {
            UInt64[][] fract = stream.Split(decPt, true);

            if (fract.Length != 2)
            {
                throw new Exception();
            }

            if (!IsNumber(fract[0]) | !IsNumber(fract[1]))
            {
                throw new Exception();
            }


            BigRational d = 0;

            for (int i = 0; i < fract[0].Length; i++)
            {
                d = d + (BigRational.Pow(10, i) * ReadDigit(fract[0][fract[0].Length - (i + 1)]));
            }

            for (int i = 1; i <= fract[1].Length; i++)
            {
                d = d + (BigRational.Pow(10, i * -1) * ReadDigit(fract[1][i - 1]));
            }

            return(d);
        }
Beispiel #2
0
        public static UInt64 Hex2Decimal(UnicodeStream stream)
        {
            UInt64 dec = 0;

            for (int i = 0; i < stream.Length; i++)
            {
                dec += (UInt64)Math.Pow(16, i) * (UInt64)ReadHexValue(stream.CharAt(stream.Length - (i + 1)));
            }

            return(dec);
        }
Beispiel #3
0
        public static UInt64 InterpretAsInteger(UnicodeStream stream)
        {
            UInt64 dec = 0;

            for (int i = 0; i < stream.Length; i++)
            {
                dec += (UInt64)Math.Pow(10, i) * (UInt64)ReadDigit(stream.CharAt(stream.Length - (i + 1)));
            }

            return(dec);
        }
Beispiel #4
0
        public static bool IsNumber(UnicodeStream stream)
        {
            for (int i = 0; i < stream.Length; i++)
            {
                if (!IsDigit(stream.CharAt(i)))
                {
                    return(false);
                }
            }

            return(true);
        }
Beispiel #5
0
        public UnicodeStream[] Split(UnicodeStream delimiter, bool removeEmptyEntries)
        {
            UInt64[][]      arr    = ArrayUtil.SplitArray(CodePoints.ToArray(), delimiter.CodePoints.ToArray(), removeEmptyEntries);
            UnicodeStream[] result = new UnicodeStream[arr.Length];

            for (int i = 0; i < arr.Length; i++)
            {
                result[i] = new UnicodeStream(arr[i]);
            }

            return(result);
        }
Beispiel #6
0
 public static BigRational InterpretAsMantissa(UnicodeStream stream) => InterpretAsMantissa(stream.CodePoints.ToArray());
Beispiel #7
0
 public int LastIndexOf(UnicodeStream stream)
 {
     return(LastIndexOf(stream.CodePoints.ToArray()));
 }
Beispiel #8
0
 public void Insert(int index, UnicodeStream str)
 {
     CodePoints.InsertRange(index, str.CodePoints);
 }
Beispiel #9
0
 public void Push(UnicodeStream stream)
 {
     CodePoints.AddRange(stream.CodePoints);
 }
Beispiel #10
0
 public bool Same(UnicodeStream stream)
 {
     return(CodePoints.SequenceEqual(stream.CodePoints));
 }