internal static string IntegralDecodingWithScaling(string code, List <Myletter> letters) { string returnedString = ""; int numberOfBits = Encoder.MinimumNumberOfBits(letters, Encoder.SmallestPosibleRange(letters)); // Console.WriteLine($"Number of bits={numberOfBits}"); int numOfLetters = letters.Sum(x => x.Quantity); List <string> allDString = new List <string>(); List <string> allGString = new List <string>(); List <int> allDDec = new List <int>(); List <int> allGDec = new List <int>(); allDString.Add(Encoder.IntegralToBinary(0, numberOfBits)); allGString.Add(Encoder.IntegralToBinary((int)Math.Pow(2, numberOfBits) - 1, numberOfBits)); allDDec.Add(0); allGDec.Add((int)Math.Pow(2, numberOfBits) - 1); // Console.WriteLine($"D[0]= {allDDec[0]} {allDString[0]}"); //Console.WriteLine($"G[0]= {allGDec[0]} {allGString[0]}"); string windowedCode = code.Substring(0, numberOfBits); double sign = Encoder.BinaryToIntegral(windowedCode); // Console.WriteLine($"Windowed code={windowedCode} Sign={sign}"); int nextReadedBit = numberOfBits; for (int n = 1; n < numOfLetters + 1; n++) { double tStar = (numOfLetters * (sign - allDDec[^ 1] + 1) - 1) / (allGDec[^ 1] - allDDec[^ 1] + 1);