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); }
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); }
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); }
public static bool IsNumber(UnicodeStream stream) { for (int i = 0; i < stream.Length; i++) { if (!IsDigit(stream.CharAt(i))) { return(false); } } return(true); }
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); }
public static BigRational InterpretAsMantissa(UnicodeStream stream) => InterpretAsMantissa(stream.CodePoints.ToArray());
public int LastIndexOf(UnicodeStream stream) { return(LastIndexOf(stream.CodePoints.ToArray())); }
public void Insert(int index, UnicodeStream str) { CodePoints.InsertRange(index, str.CodePoints); }
public void Push(UnicodeStream stream) { CodePoints.AddRange(stream.CodePoints); }
public bool Same(UnicodeStream stream) { return(CodePoints.SequenceEqual(stream.CodePoints)); }