Skip to content

Instantly share code, notes, and snippets.

@ladeak
Last active September 8, 2023 06:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ladeak/d85094e25114fe9de7fcc0f944e50e3d to your computer and use it in GitHub Desktop.
Save ladeak/d85094e25114fe9de7fcc0f944e50e3d to your computer and use it in GitHub Desktop.
Fractional

Calculating U.S. Treasury Notes Pricing

A few years ago, I worked on a type that could process double values received as real-time market data updates and helped to convert them to be displayed for humans on a UI.

The type was used to process market data updates of U.S. Treasury Notes. The pricing of U.S. Treasury Notes is detailed on the cmegroup site. In this post I will focus on the pricing of bond and note products while keeping futures aside.

The prices of these products are displayed in fractions. The price of such a product may look as 99-032. This means it is 99 full points plus 3/32s of a point plus 2/8 of 1/32s of a point. The last digit of the price can take up values of 0 2, + and 6, where plus denotes 4/8 or 1/2. Hence 99-032 equals 99 + 3/32 + 2/256 = 99.1015625. Note, that the last digit is always a multiple of 1/4th of a 1/32nd. Another example may be 100-23+ which equals 100.734375. However, this post will focus on displaying such data, converting it from a double such as 100.734375 to 100-23+.

A few years back .NET was less performant. In this post, I will revisit the original implementation as well as review 3 implementations I would consider building today to take advantage of the performance benefits of the modern .NET. Even the original implementation is significantly faster when run on .NET 8 due to the number of optimizations that have been built into the BCL and the JIT.

Please note, that the code samples in this post expect non-evil inputs. This post does not showcase production grade code snippets. Please don't use them as-is in real-world applications. The examples assume en-us as the default culture.

Original Implementation

I don't recall the exact original implementation and I omit edge cases that are not relevant for U.S. Treasury Notes, the original implementation could take shape as shown below.

public class FractionalClassic(int Integer, int Fraction32, int Fraction4)
{
    public double AsDouble() => Integer + (Fraction32 / 32.0) + (Fraction4 / 128.0);

    public override string ToString()
    {
        char lastChar = Fraction4 switch
        {
            0 => '0',
            1 => '2',
            2 => '+',
            3 => '6',
            _ => throw new ArgumentOutOfRangeException()
        };
        return $"{Integer}-{Fraction32:00}{lastChar}";
    }
}

Here I am using C# 12's primary constructor. The type accepts the Integer value which represents the full points, Fraction32 the 1/32s and Fraction4 is 1/4 of a 1/32nd. It has an additional method on top of the default methods inherited from object. AsDouble() returns the original value as a double. It also has the ToString() method overridden which uses C# interpolated string feature to format the full and fractional points into the desired string object. The original implementation probably concatenated the string as return Integer.ToString() + "-" + Fraction32.ToString("00") + lastChar; given at the time of implementation string interpolation was not yet available.

The difference between the interpolated string version above and the referenced string concatenation becomes apparent when one looks at the memory allocations. Based on my measurements with 100 fractional double values the string concatenation allocates 13 KB on the heap while the version with string interpolations allocates 7.31 KB.

Each of the following implementations shown in this post is benchmarked with BenchmarkDotNet. The benchmarks are given a double array with 100 values to be converted into string objects. The benchmark splits the double value into full and fractions points, then uses the showcased fractional type implementation to create a string.

The corresponding benchmark of the above method is implemented as:

[Benchmark]
public void ClassicToString()
{
    int i = 0;
    foreach (double price in Prices)
    {
        var integerPart = (int)price;
        var remainder = (price - integerPart) * 32;
        byte fraction32 = (byte)remainder;
        byte fraction4 = (byte)((remainder - fraction32) * 4);
        var fractional = new FractionalClassic(integerPart, fraction32, fraction4);
        DisplayPrices[i++] = fractional.ToString();
    }
}

Note, that the result string objects are not thrown away, but referenced by the DisplayPrices array. Double values that do not conform to a valid fractional number are rounded down to the nearest fraction.

Fractional Improvements

In the second part of this blog post I will incrementally improve the current solution.

Fractional

Let's introduce Fractional type. Compared to the original implementation the Fractional is a value type implemented as a record struct. This avoids an extra heap allocation, given this is typically a short lived. When passed around it gets copied by value. It has different type of fields too: it uses an int for the full points and uses byte for the fractions. Given fractional point values are limited to 32 and 4 respectively, the smaller data type is enough to represent them. The type uses required properties with essential validation in the setters. For example, it does not allow negative prices (note, that in rare real-life use-cases a negative price could be valid) and does not allow larger fractions to 31 and 4.

public record struct Fractional : ISpanFormattable
{
    private int _integer;
    private byte _fraction32;
    private byte _fraction4;

    public required int Integer
    {
        get => _integer; init
        {
            if (value < 0)
                throw new ArgumentOutOfRangeException();
            _integer = value;
        }
    }
    public required byte Fraction32
    {
        get => _fraction32; init
        {
            if (value > 31 || value < 0)
                throw new ArgumentOutOfRangeException();
            _fraction32 = value;
        }
    }
    public required byte Fraction4
    {
        get => _fraction4; init
        {
            if (value > 3 || value < 0)
                throw new ArgumentOutOfRangeException();
            _fraction4 = value;
        }
    }

    public double AsDouble() => _integer + (Fraction32 / 32.0) + (Fraction4 / 128.0);

    public string ToString(string? format, IFormatProvider? formatProvider)
    {
        Span<char> destination = stackalloc char[14];
        if (TryFormat(destination, out int written, format, formatProvider))
            return destination[0..written].ToString();
        throw new ArgumentOutOfRangeException();
    }

    public bool TryFormat(Span<char> destination, out int charsWritten, ReadOnlySpan<char> format = default, IFormatProvider? provider = default)
    {
        charsWritten = 0;
        if (!Integer.TryFormat(destination, out int currentWritten))
            return false;
        charsWritten += currentWritten;
        if (charsWritten + 1 > destination.Length)
            return false;
        destination[charsWritten++] = '-';
        if (!Fraction32.TryFormat(destination[charsWritten..], out currentWritten, "00"))
            return false;
        charsWritten += currentWritten;
        if (charsWritten + 1 > destination.Length)
            return false;

        char lastChar = Fraction4 switch
        {
            0 => '0',
            1 => '2',
            2 => '+',
            3 => '6'
        };
        destination[charsWritten++] = lastChar;
        return true;
    }

    public override string ToString() => ToString(null, null);
}

Another key difference is how it creates the string object. The ToString() method allocates an array on the stack for 14 characters. In a real application this should be a larger buffer, or in case the latter invoked TryFormat() fails, it could allocate a regular array on the heap. For simplicity this code only uses the stack allocated array. The type implements the ISpanFormattable interface that comes with the premise of a TryFormat() method. This method writes the fields of the type as a string into the provided destination buffer. Both the int and byte types implement the ISpanFormattable interface, so the code defers formatting to their TryFormat() method. The - character and the final digit are written as regular chars.

This solution brings performance improvements in terms of mean execution time and allocated memory as well:

|                 Method |       Mean |    Error |   StdDev |   Gen0 |   Gen1 | Allocated |
|----------------------- |-----------:|---------:|---------:|-------:|-------:|----------:|
|     FractionalToString | 5,071.4 ns | 47.27 ns | 41.91 ns | 0.6561 | 0.0076 |   4.06 KB |
|        ClassicToString | 6,857.8 ns | 52.74 ns | 44.04 ns | 1.1902 | 0.0153 |   7.31 KB |

FastFractional

The next iteration is called creatively the FastFractional. This post inlines the discussed methods of the type, while the complete implementation can be found on GitHub.

One of the two key differences with this type is that instead of having Fraction32 and Fraction4 properties we only have a single Fractions128 property. This not just makes the struct smaller and inherently faster to copy by value, but it also simplifies parsing the double input values.

The second key difference is the ToString() method implementation:

public record struct FastFractional : ISpanFormattable
{
    private byte _fractions128;

    public required uint Integer { get; init; }
    public required byte Fractions128
    {
        // ...
    }

    public string ToString(string? format, IFormatProvider? formatProvider)
    {
        return string.Create(CountDigits(Integer) + 4, ((Integer, Fractions128)), static (destination, state) =>
        {
            if (state.Integer > 89 && state.Integer < 128)
                BinaryPrimitives.WriteUInt64LittleEndian(MemoryMarshal.AsBytes(destination), GetInteger((int)state.Integer));
            else
                state.Integer.TryFormat(destination, out _);
            BinaryPrimitives.WriteUInt64LittleEndian(MemoryMarshal.AsBytes(destination[^4..]), GetFractions(state.Fractions128));
        });
    }

    // ...

    private static ulong GetInteger(int value)
    {
        ReadOnlySpan<ulong> table = new ulong[] { 0x20002000300039, 0x20002000310039, ... };
        return table[value - 90];
    }

    private static ulong GetFractions(int index)
    {
        ReadOnlySpan<ulong> table = new ulong[] { 0x3000300030002d, 0x3200300030002d, ... };
        return table[index];
    }

    private static int CountDigits(uint value)
    {
        // Algorithm based on https://lemire.me/blog/2021/06/03/computing-the-number-of-digits-of-an-integer-even-faster.
        ReadOnlySpan<long> table = new long[]
        {
                4294967296,
                8589934582,
                //...                
        };
        long tableValue = Unsafe.Add(ref MemoryMarshal.GetReference(table), uint.Log2(value));
        return (int)((value + tableValue) >> 32);
    }
}

The ToString() method uses the string.Create with the SpanAction overload to create the result string.

CountDigits() counts the number of chars required for the full points. The fractional points always use 3 chars and an additional - concatenating full and fractional points. The CountDigits() method uses an algorithm described by Daniel Lemire, and also used by .NET 8. The idea behind the algorithm is to calculate the number of chars required when the number is formatted as a binary number and convert that to decimal using log2 to log10 conversion formula. Negative prices are not considered by this implementation.

The SpanAction of string.Create method provides a callback, which writes the full and fractional points as number with two operations. A key observation for these numbers is that most of the values in practice fall in the [90..128] range. There might be prices higher or lower, but most real-life examples fall within this range. This gives an opportunity for an interesting optimization: we may pre-calculate the underlying byte values of the formatted number instead of formatting the integer value every time. The second optimization is that the numbers within this range are 2 or 3 characters. The 3 chars require 6 bytes, so we may use a larger, 8 byte ulong type to encode the underlying bytes of the original number. This optimization is also used by .NET 7. Finally, instead of writing the 3 characters with instructions, we can copy the ulong value with WriteUInt64LittleEndian() method as a single operation.

When the full points of the price does not fall within the [90..128] range the regular int.TryFormat() method is used to format the number as a string.

The fractional part of the price also utilizes the same idea: all values between -000 and -316 can be pre-encoded ulong numbers. The results are kept in a ulong array of 128 items. Finding the right number is looking it up in an array. Then formatting the value into the string happens by writing it using WriteUInt64LittleEndian to the destination buffer.

This approach yields a significant jump in the mean execution time on the given input sample. Note that the values of the input sample fall within the optimized range.

|                 Method |       Mean |    Error |   StdDev |   Gen0 |   Gen1 | Allocated |
|----------------------- |-----------:|---------:|---------:|-------:|-------:|----------:|
| FastFractionalToString |   736.3 ns |  9.31 ns |  8.71 ns | 0.6628 | 0.0095 |   4.06 KB |
|     FractionalToString | 5,071.4 ns | 47.27 ns | 41.91 ns | 0.6561 | 0.0076 |   4.06 KB |
|        ClassicToString | 6,857.8 ns | 52.74 ns | 44.04 ns | 1.1902 | 0.0153 |   7.31 KB |

CopyFractional

The final iteration of the type is called CopyFractional. The sample below highlights the differences compared to the previous solutions, while the complete example can be found on GitHub.

public string ToString(string? format, IFormatProvider? formatProvider)
{
    return string.Create(CountDigits(Integer) + 4, ((Integer, Fractions128)), static (destination, state) =>
    {
        ReadOnlySpan<char> calculated = "090-000090-002...";
        var startIndex = (int)(state.Integer - 90) * (7 * 128) + state.Fractions128 * 7;
        if (state.Integer > 99 && state.Integer < 128)
        {
            calculated.Slice(startIndex, 7).CopyTo(destination);
        }
        else if (state.Integer > 89 && state.Integer <= 99)
        {
            calculated.Slice(startIndex + 1, 6).CopyTo(destination);
        }
        else
        {
            state.Integer.TryFormat(destination, out _);
            BinaryPrimitives.WriteUInt64LittleEndian(MemoryMarshal.AsBytes(destination[^4..]), GetFractions(state.Fractions128));
        }
    });
}

This approach uses a similar idea to the previous solution. However, instead of writing the full and fractional parts in two iterations it uses a single copy when the value falls within the [90..128] range. All values are pre-formatted and concatenated in a single string that is stored in the application binaries. This string can be accessed using the ReadOnlySpan<char> calculated = instruction. ToString() method finds the corresponding slice of the preformatted string and copies it to the destination buffer.

The benchmarks show that this approach as the fastest on my test machine:

|                 Method |       Mean |    Error |   StdDev |   Gen0 |   Gen1 | Allocated |
|----------------------- |-----------:|---------:|---------:|-------:|-------:|----------:|
| FastFractionalToString |   736.3 ns |  9.31 ns |  8.71 ns | 0.6628 | 0.0095 |   4.06 KB |
| CopyFractionalToString |   676.9 ns | 13.01 ns | 11.54 ns | 0.6628 | 0.0095 |   4.06 KB |
|     FractionalToString | 5,071.4 ns | 47.27 ns | 41.91 ns | 0.6561 | 0.0076 |   4.06 KB |
|        ClassicToString | 6,857.8 ns | 52.74 ns | 44.04 ns | 1.1902 | 0.0153 |   7.31 KB |

However, this approach comes with a significant trade-off: the size of the binary increases by more than 60 KB as the whole preformatted string is compiled into the IL.

SIMD

A careful reader may wonder if Single instruction, multiple data, SIMD could be leveraged for the above task. While it is possible to vectorize parts of this algorithm, the final string object has to be created with a non-SIMD instruction. So far, I have not found an efficient solution to vectorize the algorithm, but if there is a managed way achieving this, I would be more than happy to learn about it. The fact that eventually the vectorized loop needs to iterate all the values of the vector one-by-one to create the individual string objects diminishes the performance benefit of using SIMD. My best attempts to vectorize the algorithm reached a mean execution time within the range of ~1000 ns.

public record struct CopyFractional : ISpanFormattable
{
private byte _fractions128;
public required uint Integer { get; init; }
public required byte Fractions128
{
get => _fractions128;
init
{
if (value > 128)
throw new ArgumentOutOfRangeException();
_fractions128 = value;
}
}
public double AsDouble() => Integer + (Fractions128 / 128.0);
public string ToString(string? format, IFormatProvider? formatProvider)
{
return string.Create(CountDigits(Integer) + 4, ((Integer, Fractions128)), static (destination, state) =>
{
ReadOnlySpan<char> calculated = "090-000090-002090-00+090-006090-010090-012090-01+090-016090-020090-022090-02+090-026090-030090-032090-03+090-036090-040090-042090-04+090-046090-050090-052090-05+090-056090-060090-062090-06+090-066090-070090-072090-07+090-076090-080090-082090-08+090-086090-090090-092090-09+090-096090-100090-102090-10+090-106090-110090-112090-11+090-116090-120090-122090-12+090-126090-130090-132090-13+090-136090-140090-142090-14+090-146090-150090-152090-15+090-156090-160090-162090-16+090-166090-170090-172090-17+090-176090-180090-182090-18+090-186090-190090-192090-19+090-196090-200090-202090-20+090-206090-210090-212090-21+090-216090-220090-222090-22+090-226090-230090-232090-23+090-236090-240090-242090-24+090-246090-250090-252090-25+090-256090-260090-262090-26+090-266090-270090-272090-27+090-276090-280090-282090-28+090-286090-290090-292090-29+090-296090-300090-302090-30+090-306090-310090-312090-31+090-316091-000091-002091-00+091-006091-010091-012091-01+091-016091-020091-022091-02+091-026091-030091-032091-03+091-036091-040091-042091-04+091-046091-050091-052091-05+091-056091-060091-062091-06+091-066091-070091-072091-07+091-076091-080091-082091-08+091-086091-090091-092091-09+091-096091-100091-102091-10+091-106091-110091-112091-11+091-116091-120091-122091-12+091-126091-130091-132091-13+091-136091-140091-142091-14+091-146091-150091-152091-15+091-156091-160091-162091-16+091-166091-170091-172091-17+091-176091-180091-182091-18+091-186091-190091-192091-19+091-196091-200091-202091-20+091-206091-210091-212091-21+091-216091-220091-222091-22+091-226091-230091-232091-23+091-236091-240091-242091-24+091-246091-250091-252091-25+091-256091-260091-262091-26+091-266091-270091-272091-27+091-276091-280091-282091-28+091-286091-290091-292091-29+091-296091-300091-302091-30+091-306091-310091-312091-31+091-316092-000092-002092-00+092-006092-010092-012092-01+092-016092-020092-022092-02+092-026092-030092-032092-03+092-036092-040092-042092-04+092-046092-050092-052092-05+092-056092-060092-062092-06+092-066092-070092-072092-07+092-076092-080092-082092-08+092-086092-090092-092092-09+092-096092-100092-102092-10+092-106092-110092-112092-11+092-116092-120092-122092-12+092-126092-130092-132092-13+092-136092-140092-142092-14+092-146092-150092-152092-15+092-156092-160092-162092-16+092-166092-170092-172092-17+092-176092-180092-182092-18+092-186092-190092-192092-19+092-196092-200092-202092-20+092-206092-210092-212092-21+092-216092-220092-222092-22+092-226092-230092-232092-23+092-236092-240092-242092-24+092-246092-250092-252092-25+092-256092-260092-262092-26+092-266092-270092-272092-27+092-276092-280092-282092-28+092-286092-290092-292092-29+092-296092-300092-302092-30+092-306092-310092-312092-31+092-316093-000093-002093-00+093-006093-010093-012093-01+093-016093-020093-022093-02+093-026093-030093-032093-03+093-036093-040093-042093-04+093-046093-050093-052093-05+093-056093-060093-062093-06+093-066093-070093-072093-07+093-076093-080093-082093-08+093-086093-090093-092093-09+093-096093-100093-102093-10+093-106093-110093-112093-11+093-116093-120093-122093-12+093-126093-130093-132093-13+093-136093-140093-142093-14+093-146093-150093-152093-15+093-156093-160093-162093-16+093-166093-170093-172093-17+093-176093-180093-182093-18+093-186093-190093-192093-19+093-196093-200093-202093-20+093-206093-210093-212093-21+093-216093-220093-222093-22+093-226093-230093-232093-23+093-236093-240093-242093-24+093-246093-250093-252093-25+093-256093-260093-262093-26+093-266093-270093-272093-27+093-276093-280093-282093-28+093-286093-290093-292093-29+093-296093-300093-302093-30+093-306093-310093-312093-31+093-316094-000094-002094-00+094-006094-010094-012094-01+094-016094-020094-022094-02+094-026094-030094-032094-03+094-036094-040094-042094-04+094-046094-050094-052094-05+094-056094-060094-062094-06+094-066094-070094-072094-07+094-076094-080094-082094-08+094-086094-090094-092094-09+094-096094-100094-102094-10+094-106094-110094-112094-11+094-116094-120094-122094-12+094-126094-130094-132094-13+094-136094-140094-142094-14+094-146094-150094-152094-15+094-156094-160094-162094-16+094-166094-170094-172094-17+094-176094-180094-182094-18+094-186094-190094-192094-19+094-196094-200094-202094-20+094-206094-210094-212094-21+094-216094-220094-222094-22+094-226094-230094-232094-23+094-236094-240094-242094-24+094-246094-250094-252094-25+094-256094-260094-262094-26+094-266094-270094-272094-27+094-276094-280094-282094-28+094-286094-290094-292094-29+094-296094-300094-302094-30+094-306094-310094-312094-31+094-316095-000095-002095-00+095-006095-010095-012095-01+095-016095-020095-022095-02+095-026095-030095-032095-03+095-036095-040095-042095-04+095-046095-050095-052095-05+095-056095-060095-062095-06+095-066095-070095-072095-07+095-076095-080095-082095-08+095-086095-090095-092095-09+095-096095-100095-102095-10+095-106095-110095-112095-11+095-116095-120095-122095-12+095-126095-130095-132095-13+095-136095-140095-142095-14+095-146095-150095-152095-15+095-156095-160095-162095-16+095-166095-170095-172095-17+095-176095-180095-182095-18+095-186095-190095-192095-19+095-196095-200095-202095-20+095-206095-210095-212095-21+095-216095-220095-222095-22+095-226095-230095-232095-23+095-236095-240095-242095-24+095-246095-250095-252095-25+095-256095-260095-262095-26+095-266095-270095-272095-27+095-276095-280095-282095-28+095-286095-290095-292095-29+095-296095-300095-302095-30+095-306095-310095-312095-31+095-316096-000096-002096-00+096-006096-010096-012096-01+096-016096-020096-022096-02+096-026096-030096-032096-03+096-036096-040096-042096-04+096-046096-050096-052096-05+096-056096-060096-062096-06+096-066096-070096-072096-07+096-076096-080096-082096-08+096-086096-090096-092096-09+096-096096-100096-102096-10+096-106096-110096-112096-11+096-116096-120096-122096-12+096-126096-130096-132096-13+096-136096-140096-142096-14+096-146096-150096-152096-15+096-156096-160096-162096-16+096-166096-170096-172096-17+096-176096-180096-182096-18+096-186096-190096-192096-19+096-196096-200096-202096-20+096-206096-210096-212096-21+096-216096-220096-222096-22+096-226096-230096-232096-23+096-236096-240096-242096-24+096-246096-250096-252096-25+096-256096-260096-262096-26+096-266096-270096-272096-27+096-276096-280096-282096-28+096-286096-290096-292096-29+096-296096-300096-302096-30+096-306096-310096-312096-31+096-316097-000097-002097-00+097-006097-010097-012097-01+097-016097-020097-022097-02+097-026097-030097-032097-03+097-036097-040097-042097-04+097-046097-050097-052097-05+097-056097-060097-062097-06+097-066097-070097-072097-07+097-076097-080097-082097-08+097-086097-090097-092097-09+097-096097-100097-102097-10+097-106097-110097-112097-11+097-116097-120097-122097-12+097-126097-130097-132097-13+097-136097-140097-142097-14+097-146097-150097-152097-15+097-156097-160097-162097-16+097-166097-170097-172097-17+097-176097-180097-182097-18+097-186097-190097-192097-19+097-196097-200097-202097-20+097-206097-210097-212097-21+097-216097-220097-222097-22+097-226097-230097-232097-23+097-236097-240097-242097-24+097-246097-250097-252097-25+097-256097-260097-262097-26+097-266097-270097-272097-27+097-276097-280097-282097-28+097-286097-290097-292097-29+097-296097-300097-302097-30+097-306097-310097-312097-31+097-316098-000098-002098-00+098-006098-010098-012098-01+098-016098-020098-022098-02+098-026098-030098-032098-03+098-036098-040098-042098-04+098-046098-050098-052098-05+098-056098-060098-062098-06+098-066098-070098-072098-07+098-076098-080098-082098-08+098-086098-090098-092098-09+098-096098-100098-102098-10+098-106098-110098-112098-11+098-116098-120098-122098-12+098-126098-130098-132098-13+098-136098-140098-142098-14+098-146098-150098-152098-15+098-156098-160098-162098-16+098-166098-170098-172098-17+098-176098-180098-182098-18+098-186098-190098-192098-19+098-196098-200098-202098-20+098-206098-210098-212098-21+098-216098-220098-222098-22+098-226098-230098-232098-23+098-236098-240098-242098-24+098-246098-250098-252098-25+098-256098-260098-262098-26+098-266098-270098-272098-27+098-276098-280098-282098-28+098-286098-290098-292098-29+098-296098-300098-302098-30+098-306098-310098-312098-31+098-316099-000099-002099-00+099-006099-010099-012099-01+099-016099-020099-022099-02+099-026099-030099-032099-03+099-036099-040099-042099-04+099-046099-050099-052099-05+099-056099-060099-062099-06+099-066099-070099-072099-07+099-076099-080099-082099-08+099-086099-090099-092099-09+099-096099-100099-102099-10+099-106099-110099-112099-11+099-116099-120099-122099-12+099-126099-130099-132099-13+099-136099-140099-142099-14+099-146099-150099-152099-15+099-156099-160099-162099-16+099-166099-170099-172099-17+099-176099-180099-182099-18+099-186099-190099-192099-19+099-196099-200099-202099-20+099-206099-210099-212099-21+099-216099-220099-222099-22+099-226099-230099-232099-23+099-236099-240099-242099-24+099-246099-250099-252099-25+099-256099-260099-262099-26+099-266099-270099-272099-27+099-276099-280099-282099-28+099-286099-290099-292099-29+099-296099-300099-302099-30+099-306099-310099-312099-31+099-316100-000100-002100-00+100-006100-010100-012100-01+100-016100-020100-022100-02+100-026100-030100-032100-03+100-036100-040100-042100-04+100-046100-050100-052100-05+100-056100-060100-062100-06+100-066100-070100-072100-07+100-076100-080100-082100-08+100-086100-090100-092100-09+100-096100-100100-102100-10+100-106100-110100-112100-11+100-116100-120100-122100-12+100-126100-130100-132100-13+100-136100-140100-142100-14+100-146100-150100-152100-15+100-156100-160100-162100-16+100-166100-170100-172100-17+100-176100-180100-182100-18+100-186100-190100-192100-19+100-196100-200100-202100-20+100-206100-210100-212100-21+100-216100-220100-222100-22+100-226100-230100-232100-23+100-236100-240100-242100-24+100-246100-250100-252100-25+100-256100-260100-262100-26+100-266100-270100-272100-27+100-276100-280100-282100-28+100-286100-290100-292100-29+100-296100-300100-302100-30+100-306100-310100-312100-31+100-316101-000101-002101-00+101-006101-010101-012101-01+101-016101-020101-022101-02+101-026101-030101-032101-03+101-036101-040101-042101-04+101-046101-050101-052101-05+101-056101-060101-062101-06+101-066101-070101-072101-07+101-076101-080101-082101-08+101-086101-090101-092101-09+101-096101-100101-102101-10+101-106101-110101-112101-11+101-116101-120101-122101-12+101-126101-130101-132101-13+101-136101-140101-142101-14+101-146101-150101-152101-15+101-156101-160101-162101-16+101-166101-170101-172101-17+101-176101-180101-182101-18+101-186101-190101-192101-19+101-196101-200101-202101-20+101-206101-210101-212101-21+101-216101-220101-222101-22+101-226101-230101-232101-23+101-236101-240101-242101-24+101-246101-250101-252101-25+101-256101-260101-262101-26+101-266101-270101-272101-27+101-276101-280101-282101-28+101-286101-290101-292101-29+101-296101-300101-302101-30+101-306101-310101-312101-31+101-316102-000102-002102-00+102-006102-010102-012102-01+102-016102-020102-022102-02+102-026102-030102-032102-03+102-036102-040102-042102-04+102-046102-050102-052102-05+102-056102-060102-062102-06+102-066102-070102-072102-07+102-076102-080102-082102-08+102-086102-090102-092102-09+102-096102-100102-102102-10+102-106102-110102-112102-11+102-116102-120102-122102-12+102-126102-130102-132102-13+102-136102-140102-142102-14+102-146102-150102-152102-15+102-156102-160102-162102-16+102-166102-170102-172102-17+102-176102-180102-182102-18+102-186102-190102-192102-19+102-196102-200102-202102-20+102-206102-210102-212102-21+102-216102-220102-222102-22+102-226102-230102-232102-23+102-236102-240102-242102-24+102-246102-250102-252102-25+102-256102-260102-262102-26+102-266102-270102-272102-27+102-276102-280102-282102-28+102-286102-290102-292102-29+102-296102-300102-302102-30+102-306102-310102-312102-31+102-316103-000103-002103-00+103-006103-010103-012103-01+103-016103-020103-022103-02+103-026103-030103-032103-03+103-036103-040103-042103-04+103-046103-050103-052103-05+103-056103-060103-062103-06+103-066103-070103-072103-07+103-076103-080103-082103-08+103-086103-090103-092103-09+103-096103-100103-102103-10+103-106103-110103-112103-11+103-116103-120103-122103-12+103-126103-130103-132103-13+103-136103-140103-142103-14+103-146103-150103-152103-15+103-156103-160103-162103-16+103-166103-170103-172103-17+103-176103-180103-182103-18+103-186103-190103-192103-19+103-196103-200103-202103-20+103-206103-210103-212103-21+103-216103-220103-222103-22+103-226103-230103-232103-23+103-236103-240103-242103-24+103-246103-250103-252103-25+103-256103-260103-262103-26+103-266103-270103-272103-27+103-276103-280103-282103-28+103-286103-290103-292103-29+103-296103-300103-302103-30+103-306103-310103-312103-31+103-316104-000104-002104-00+104-006104-010104-012104-01+104-016104-020104-022104-02+104-026104-030104-032104-03+104-036104-040104-042104-04+104-046104-050104-052104-05+104-056104-060104-062104-06+104-066104-070104-072104-07+104-076104-080104-082104-08+104-086104-090104-092104-09+104-096104-100104-102104-10+104-106104-110104-112104-11+104-116104-120104-122104-12+104-126104-130104-132104-13+104-136104-140104-142104-14+104-146104-150104-152104-15+104-156104-160104-162104-16+104-166104-170104-172104-17+104-176104-180104-182104-18+104-186104-190104-192104-19+104-196104-200104-202104-20+104-206104-210104-212104-21+104-216104-220104-222104-22+104-226104-230104-232104-23+104-236104-240104-242104-24+104-246104-250104-252104-25+104-256104-260104-262104-26+104-266104-270104-272104-27+104-276104-280104-282104-28+104-286104-290104-292104-29+104-296104-300104-302104-30+104-306104-310104-312104-31+104-316105-000105-002105-00+105-006105-010105-012105-01+105-016105-020105-022105-02+105-026105-030105-032105-03+105-036105-040105-042105-04+105-046105-050105-052105-05+105-056105-060105-062105-06+105-066105-070105-072105-07+105-076105-080105-082105-08+105-086105-090105-092105-09+105-096105-100105-102105-10+105-106105-110105-112105-11+105-116105-120105-122105-12+105-126105-130105-132105-13+105-136105-140105-142105-14+105-146105-150105-152105-15+105-156105-160105-162105-16+105-166105-170105-172105-17+105-176105-180105-182105-18+105-186105-190105-192105-19+105-196105-200105-202105-20+105-206105-210105-212105-21+105-216105-220105-222105-22+105-226105-230105-232105-23+105-236105-240105-242105-24+105-246105-250105-252105-25+105-256105-260105-262105-26+105-266105-270105-272105-27+105-276105-280105-282105-28+105-286105-290105-292105-29+105-296105-300105-302105-30+105-306105-310105-312105-31+105-316106-000106-002106-00+106-006106-010106-012106-01+106-016106-020106-022106-02+106-026106-030106-032106-03+106-036106-040106-042106-04+106-046106-050106-052106-05+106-056106-060106-062106-06+106-066106-070106-072106-07+106-076106-080106-082106-08+106-086106-090106-092106-09+106-096106-100106-102106-10+106-106106-110106-112106-11+106-116106-120106-122106-12+106-126106-130106-132106-13+106-136106-140106-142106-14+106-146106-150106-152106-15+106-156106-160106-162106-16+106-166106-170106-172106-17+106-176106-180106-182106-18+106-186106-190106-192106-19+106-196106-200106-202106-20+106-206106-210106-212106-21+106-216106-220106-222106-22+106-226106-230106-232106-23+106-236106-240106-242106-24+106-246106-250106-252106-25+106-256106-260106-262106-26+106-266106-270106-272106-27+106-276106-280106-282106-28+106-286106-290106-292106-29+106-296106-300106-302106-30+106-306106-310106-312106-31+106-316107-000107-002107-00+107-006107-010107-012107-01+107-016107-020107-022107-02+107-026107-030107-032107-03+107-036107-040107-042107-04+107-046107-050107-052107-05+107-056107-060107-062107-06+107-066107-070107-072107-07+107-076107-080107-082107-08+107-086107-090107-092107-09+107-096107-100107-102107-10+107-106107-110107-112107-11+107-116107-120107-122107-12+107-126107-130107-132107-13+107-136107-140107-142107-14+107-146107-150107-152107-15+107-156107-160107-162107-16+107-166107-170107-172107-17+107-176107-180107-182107-18+107-186107-190107-192107-19+107-196107-200107-202107-20+107-206107-210107-212107-21+107-216107-220107-222107-22+107-226107-230107-232107-23+107-236107-240107-242107-24+107-246107-250107-252107-25+107-256107-260107-262107-26+107-266107-270107-272107-27+107-276107-280107-282107-28+107-286107-290107-292107-29+107-296107-300107-302107-30+107-306107-310107-312107-31+107-316108-000108-002108-00+108-006108-010108-012108-01+108-016108-020108-022108-02+108-026108-030108-032108-03+108-036108-040108-042108-04+108-046108-050108-052108-05+108-056108-060108-062108-06+108-066108-070108-072108-07+108-076108-080108-082108-08+108-086108-090108-092108-09+108-096108-100108-102108-10+108-106108-110108-112108-11+108-116108-120108-122108-12+108-126108-130108-132108-13+108-136108-140108-142108-14+108-146108-150108-152108-15+108-156108-160108-162108-16+108-166108-170108-172108-17+108-176108-180108-182108-18+108-186108-190108-192108-19+108-196108-200108-202108-20+108-206108-210108-212108-21+108-216108-220108-222108-22+108-226108-230108-232108-23+108-236108-240108-242108-24+108-246108-250108-252108-25+108-256108-260108-262108-26+108-266108-270108-272108-27+108-276108-280108-282108-28+108-286108-290108-292108-29+108-296108-300108-302108-30+108-306108-310108-312108-31+108-316109-000109-002109-00+109-006109-010109-012109-01+109-016109-020109-022109-02+109-026109-030109-032109-03+109-036109-040109-042109-04+109-046109-050109-052109-05+109-056109-060109-062109-06+109-066109-070109-072109-07+109-076109-080109-082109-08+109-086109-090109-092109-09+109-096109-100109-102109-10+109-106109-110109-112109-11+109-116109-120109-122109-12+109-126109-130109-132109-13+109-136109-140109-142109-14+109-146109-150109-152109-15+109-156109-160109-162109-16+109-166109-170109-172109-17+109-176109-180109-182109-18+109-186109-190109-192109-19+109-196109-200109-202109-20+109-206109-210109-212109-21+109-216109-220109-222109-22+109-226109-230109-232109-23+109-236109-240109-242109-24+109-246109-250109-252109-25+109-256109-260109-262109-26+109-266109-270109-272109-27+109-276109-280109-282109-28+109-286109-290109-292109-29+109-296109-300109-302109-30+109-306109-310109-312109-31+109-316110-000110-002110-00+110-006110-010110-012110-01+110-016110-020110-022110-02+110-026110-030110-032110-03+110-036110-040110-042110-04+110-046110-050110-052110-05+110-056110-060110-062110-06+110-066110-070110-072110-07+110-076110-080110-082110-08+110-086110-090110-092110-09+110-096110-100110-102110-10+110-106110-110110-112110-11+110-116110-120110-122110-12+110-126110-130110-132110-13+110-136110-140110-142110-14+110-146110-150110-152110-15+110-156110-160110-162110-16+110-166110-170110-172110-17+110-176110-180110-182110-18+110-186110-190110-192110-19+110-196110-200110-202110-20+110-206110-210110-212110-21+110-216110-220110-222110-22+110-226110-230110-232110-23+110-236110-240110-242110-24+110-246110-250110-252110-25+110-256110-260110-262110-26+110-266110-270110-272110-27+110-276110-280110-282110-28+110-286110-290110-292110-29+110-296110-300110-302110-30+110-306110-310110-312110-31+110-316111-000111-002111-00+111-006111-010111-012111-01+111-016111-020111-022111-02+111-026111-030111-032111-03+111-036111-040111-042111-04+111-046111-050111-052111-05+111-056111-060111-062111-06+111-066111-070111-072111-07+111-076111-080111-082111-08+111-086111-090111-092111-09+111-096111-100111-102111-10+111-106111-110111-112111-11+111-116111-120111-122111-12+111-126111-130111-132111-13+111-136111-140111-142111-14+111-146111-150111-152111-15+111-156111-160111-162111-16+111-166111-170111-172111-17+111-176111-180111-182111-18+111-186111-190111-192111-19+111-196111-200111-202111-20+111-206111-210111-212111-21+111-216111-220111-222111-22+111-226111-230111-232111-23+111-236111-240111-242111-24+111-246111-250111-252111-25+111-256111-260111-262111-26+111-266111-270111-272111-27+111-276111-280111-282111-28+111-286111-290111-292111-29+111-296111-300111-302111-30+111-306111-310111-312111-31+111-316112-000112-002112-00+112-006112-010112-012112-01+112-016112-020112-022112-02+112-026112-030112-032112-03+112-036112-040112-042112-04+112-046112-050112-052112-05+112-056112-060112-062112-06+112-066112-070112-072112-07+112-076112-080112-082112-08+112-086112-090112-092112-09+112-096112-100112-102112-10+112-106112-110112-112112-11+112-116112-120112-122112-12+112-126112-130112-132112-13+112-136112-140112-142112-14+112-146112-150112-152112-15+112-156112-160112-162112-16+112-166112-170112-172112-17+112-176112-180112-182112-18+112-186112-190112-192112-19+112-196112-200112-202112-20+112-206112-210112-212112-21+112-216112-220112-222112-22+112-226112-230112-232112-23+112-236112-240112-242112-24+112-246112-250112-252112-25+112-256112-260112-262112-26+112-266112-270112-272112-27+112-276112-280112-282112-28+112-286112-290112-292112-29+112-296112-300112-302112-30+112-306112-310112-312112-31+112-316113-000113-002113-00+113-006113-010113-012113-01+113-016113-020113-022113-02+113-026113-030113-032113-03+113-036113-040113-042113-04+113-046113-050113-052113-05+113-056113-060113-062113-06+113-066113-070113-072113-07+113-076113-080113-082113-08+113-086113-090113-092113-09+113-096113-100113-102113-10+113-106113-110113-112113-11+113-116113-120113-122113-12+113-126113-130113-132113-13+113-136113-140113-142113-14+113-146113-150113-152113-15+113-156113-160113-162113-16+113-166113-170113-172113-17+113-176113-180113-182113-18+113-186113-190113-192113-19+113-196113-200113-202113-20+113-206113-210113-212113-21+113-216113-220113-222113-22+113-226113-230113-232113-23+113-236113-240113-242113-24+113-246113-250113-252113-25+113-256113-260113-262113-26+113-266113-270113-272113-27+113-276113-280113-282113-28+113-286113-290113-292113-29+113-296113-300113-302113-30+113-306113-310113-312113-31+113-316114-000114-002114-00+114-006114-010114-012114-01+114-016114-020114-022114-02+114-026114-030114-032114-03+114-036114-040114-042114-04+114-046114-050114-052114-05+114-056114-060114-062114-06+114-066114-070114-072114-07+114-076114-080114-082114-08+114-086114-090114-092114-09+114-096114-100114-102114-10+114-106114-110114-112114-11+114-116114-120114-122114-12+114-126114-130114-132114-13+114-136114-140114-142114-14+114-146114-150114-152114-15+114-156114-160114-162114-16+114-166114-170114-172114-17+114-176114-180114-182114-18+114-186114-190114-192114-19+114-196114-200114-202114-20+114-206114-210114-212114-21+114-216114-220114-222114-22+114-226114-230114-232114-23+114-236114-240114-242114-24+114-246114-250114-252114-25+114-256114-260114-262114-26+114-266114-270114-272114-27+114-276114-280114-282114-28+114-286114-290114-292114-29+114-296114-300114-302114-30+114-306114-310114-312114-31+114-316115-000115-002115-00+115-006115-010115-012115-01+115-016115-020115-022115-02+115-026115-030115-032115-03+115-036115-040115-042115-04+115-046115-050115-052115-05+115-056115-060115-062115-06+115-066115-070115-072115-07+115-076115-080115-082115-08+115-086115-090115-092115-09+115-096115-100115-102115-10+115-106115-110115-112115-11+115-116115-120115-122115-12+115-126115-130115-132115-13+115-136115-140115-142115-14+115-146115-150115-152115-15+115-156115-160115-162115-16+115-166115-170115-172115-17+115-176115-180115-182115-18+115-186115-190115-192115-19+115-196115-200115-202115-20+115-206115-210115-212115-21+115-216115-220115-222115-22+115-226115-230115-232115-23+115-236115-240115-242115-24+115-246115-250115-252115-25+115-256115-260115-262115-26+115-266115-270115-272115-27+115-276115-280115-282115-28+115-286115-290115-292115-29+115-296115-300115-302115-30+115-306115-310115-312115-31+115-316116-000116-002116-00+116-006116-010116-012116-01+116-016116-020116-022116-02+116-026116-030116-032116-03+116-036116-040116-042116-04+116-046116-050116-052116-05+116-056116-060116-062116-06+116-066116-070116-072116-07+116-076116-080116-082116-08+116-086116-090116-092116-09+116-096116-100116-102116-10+116-106116-110116-112116-11+116-116116-120116-122116-12+116-126116-130116-132116-13+116-136116-140116-142116-14+116-146116-150116-152116-15+116-156116-160116-162116-16+116-166116-170116-172116-17+116-176116-180116-182116-18+116-186116-190116-192116-19+116-196116-200116-202116-20+116-206116-210116-212116-21+116-216116-220116-222116-22+116-226116-230116-232116-23+116-236116-240116-242116-24+116-246116-250116-252116-25+116-256116-260116-262116-26+116-266116-270116-272116-27+116-276116-280116-282116-28+116-286116-290116-292116-29+116-296116-300116-302116-30+116-306116-310116-312116-31+116-316117-000117-002117-00+117-006117-010117-012117-01+117-016117-020117-022117-02+117-026117-030117-032117-03+117-036117-040117-042117-04+117-046117-050117-052117-05+117-056117-060117-062117-06+117-066117-070117-072117-07+117-076117-080117-082117-08+117-086117-090117-092117-09+117-096117-100117-102117-10+117-106117-110117-112117-11+117-116117-120117-122117-12+117-126117-130117-132117-13+117-136117-140117-142117-14+117-146117-150117-152117-15+117-156117-160117-162117-16+117-166117-170117-172117-17+117-176117-180117-182117-18+117-186117-190117-192117-19+117-196117-200117-202117-20+117-206117-210117-212117-21+117-216117-220117-222117-22+117-226117-230117-232117-23+117-236117-240117-242117-24+117-246117-250117-252117-25+117-256117-260117-262117-26+117-266117-270117-272117-27+117-276117-280117-282117-28+117-286117-290117-292117-29+117-296117-300117-302117-30+117-306117-310117-312117-31+117-316118-000118-002118-00+118-006118-010118-012118-01+118-016118-020118-022118-02+118-026118-030118-032118-03+118-036118-040118-042118-04+118-046118-050118-052118-05+118-056118-060118-062118-06+118-066118-070118-072118-07+118-076118-080118-082118-08+118-086118-090118-092118-09+118-096118-100118-102118-10+118-106118-110118-112118-11+118-116118-120118-122118-12+118-126118-130118-132118-13+118-136118-140118-142118-14+118-146118-150118-152118-15+118-156118-160118-162118-16+118-166118-170118-172118-17+118-176118-180118-182118-18+118-186118-190118-192118-19+118-196118-200118-202118-20+118-206118-210118-212118-21+118-216118-220118-222118-22+118-226118-230118-232118-23+118-236118-240118-242118-24+118-246118-250118-252118-25+118-256118-260118-262118-26+118-266118-270118-272118-27+118-276118-280118-282118-28+118-286118-290118-292118-29+118-296118-300118-302118-30+118-306118-310118-312118-31+118-316119-000119-002119-00+119-006119-010119-012119-01+119-016119-020119-022119-02+119-026119-030119-032119-03+119-036119-040119-042119-04+119-046119-050119-052119-05+119-056119-060119-062119-06+119-066119-070119-072119-07+119-076119-080119-082119-08+119-086119-090119-092119-09+119-096119-100119-102119-10+119-106119-110119-112119-11+119-116119-120119-122119-12+119-126119-130119-132119-13+119-136119-140119-142119-14+119-146119-150119-152119-15+119-156119-160119-162119-16+119-166119-170119-172119-17+119-176119-180119-182119-18+119-186119-190119-192119-19+119-196119-200119-202119-20+119-206119-210119-212119-21+119-216119-220119-222119-22+119-226119-230119-232119-23+119-236119-240119-242119-24+119-246119-250119-252119-25+119-256119-260119-262119-26+119-266119-270119-272119-27+119-276119-280119-282119-28+119-286119-290119-292119-29+119-296119-300119-302119-30+119-306119-310119-312119-31+119-316120-000120-002120-00+120-006120-010120-012120-01+120-016120-020120-022120-02+120-026120-030120-032120-03+120-036120-040120-042120-04+120-046120-050120-052120-05+120-056120-060120-062120-06+120-066120-070120-072120-07+120-076120-080120-082120-08+120-086120-090120-092120-09+120-096120-100120-102120-10+120-106120-110120-112120-11+120-116120-120120-122120-12+120-126120-130120-132120-13+120-136120-140120-142120-14+120-146120-150120-152120-15+120-156120-160120-162120-16+120-166120-170120-172120-17+120-176120-180120-182120-18+120-186120-190120-192120-19+120-196120-200120-202120-20+120-206120-210120-212120-21+120-216120-220120-222120-22+120-226120-230120-232120-23+120-236120-240120-242120-24+120-246120-250120-252120-25+120-256120-260120-262120-26+120-266120-270120-272120-27+120-276120-280120-282120-28+120-286120-290120-292120-29+120-296120-300120-302120-30+120-306120-310120-312120-31+120-316121-000121-002121-00+121-006121-010121-012121-01+121-016121-020121-022121-02+121-026121-030121-032121-03+121-036121-040121-042121-04+121-046121-050121-052121-05+121-056121-060121-062121-06+121-066121-070121-072121-07+121-076121-080121-082121-08+121-086121-090121-092121-09+121-096121-100121-102121-10+121-106121-110121-112121-11+121-116121-120121-122121-12+121-126121-130121-132121-13+121-136121-140121-142121-14+121-146121-150121-152121-15+121-156121-160121-162121-16+121-166121-170121-172121-17+121-176121-180121-182121-18+121-186121-190121-192121-19+121-196121-200121-202121-20+121-206121-210121-212121-21+121-216121-220121-222121-22+121-226121-230121-232121-23+121-236121-240121-242121-24+121-246121-250121-252121-25+121-256121-260121-262121-26+121-266121-270121-272121-27+121-276121-280121-282121-28+121-286121-290121-292121-29+121-296121-300121-302121-30+121-306121-310121-312121-31+121-316122-000122-002122-00+122-006122-010122-012122-01+122-016122-020122-022122-02+122-026122-030122-032122-03+122-036122-040122-042122-04+122-046122-050122-052122-05+122-056122-060122-062122-06+122-066122-070122-072122-07+122-076122-080122-082122-08+122-086122-090122-092122-09+122-096122-100122-102122-10+122-106122-110122-112122-11+122-116122-120122-122122-12+122-126122-130122-132122-13+122-136122-140122-142122-14+122-146122-150122-152122-15+122-156122-160122-162122-16+122-166122-170122-172122-17+122-176122-180122-182122-18+122-186122-190122-192122-19+122-196122-200122-202122-20+122-206122-210122-212122-21+122-216122-220122-222122-22+122-226122-230122-232122-23+122-236122-240122-242122-24+122-246122-250122-252122-25+122-256122-260122-262122-26+122-266122-270122-272122-27+122-276122-280122-282122-28+122-286122-290122-292122-29+122-296122-300122-302122-30+122-306122-310122-312122-31+122-316123-000123-002123-00+123-006123-010123-012123-01+123-016123-020123-022123-02+123-026123-030123-032123-03+123-036123-040123-042123-04+123-046123-050123-052123-05+123-056123-060123-062123-06+123-066123-070123-072123-07+123-076123-080123-082123-08+123-086123-090123-092123-09+123-096123-100123-102123-10+123-106123-110123-112123-11+123-116123-120123-122123-12+123-126123-130123-132123-13+123-136123-140123-142123-14+123-146123-150123-152123-15+123-156123-160123-162123-16+123-166123-170123-172123-17+123-176123-180123-182123-18+123-186123-190123-192123-19+123-196123-200123-202123-20+123-206123-210123-212123-21+123-216123-220123-222123-22+123-226123-230123-232123-23+123-236123-240123-242123-24+123-246123-250123-252123-25+123-256123-260123-262123-26+123-266123-270123-272123-27+123-276123-280123-282123-28+123-286123-290123-292123-29+123-296123-300123-302123-30+123-306123-310123-312123-31+123-316124-000124-002124-00+124-006124-010124-012124-01+124-016124-020124-022124-02+124-026124-030124-032124-03+124-036124-040124-042124-04+124-046124-050124-052124-05+124-056124-060124-062124-06+124-066124-070124-072124-07+124-076124-080124-082124-08+124-086124-090124-092124-09+124-096124-100124-102124-10+124-106124-110124-112124-11+124-116124-120124-122124-12+124-126124-130124-132124-13+124-136124-140124-142124-14+124-146124-150124-152124-15+124-156124-160124-162124-16+124-166124-170124-172124-17+124-176124-180124-182124-18+124-186124-190124-192124-19+124-196124-200124-202124-20+124-206124-210124-212124-21+124-216124-220124-222124-22+124-226124-230124-232124-23+124-236124-240124-242124-24+124-246124-250124-252124-25+124-256124-260124-262124-26+124-266124-270124-272124-27+124-276124-280124-282124-28+124-286124-290124-292124-29+124-296124-300124-302124-30+124-306124-310124-312124-31+124-316125-000125-002125-00+125-006125-010125-012125-01+125-016125-020125-022125-02+125-026125-030125-032125-03+125-036125-040125-042125-04+125-046125-050125-052125-05+125-056125-060125-062125-06+125-066125-070125-072125-07+125-076125-080125-082125-08+125-086125-090125-092125-09+125-096125-100125-102125-10+125-106125-110125-112125-11+125-116125-120125-122125-12+125-126125-130125-132125-13+125-136125-140125-142125-14+125-146125-150125-152125-15+125-156125-160125-162125-16+125-166125-170125-172125-17+125-176125-180125-182125-18+125-186125-190125-192125-19+125-196125-200125-202125-20+125-206125-210125-212125-21+125-216125-220125-222125-22+125-226125-230125-232125-23+125-236125-240125-242125-24+125-246125-250125-252125-25+125-256125-260125-262125-26+125-266125-270125-272125-27+125-276125-280125-282125-28+125-286125-290125-292125-29+125-296125-300125-302125-30+125-306125-310125-312125-31+125-316126-000126-002126-00+126-006126-010126-012126-01+126-016126-020126-022126-02+126-026126-030126-032126-03+126-036126-040126-042126-04+126-046126-050126-052126-05+126-056126-060126-062126-06+126-066126-070126-072126-07+126-076126-080126-082126-08+126-086126-090126-092126-09+126-096126-100126-102126-10+126-106126-110126-112126-11+126-116126-120126-122126-12+126-126126-130126-132126-13+126-136126-140126-142126-14+126-146126-150126-152126-15+126-156126-160126-162126-16+126-166126-170126-172126-17+126-176126-180126-182126-18+126-186126-190126-192126-19+126-196126-200126-202126-20+126-206126-210126-212126-21+126-216126-220126-222126-22+126-226126-230126-232126-23+126-236126-240126-242126-24+126-246126-250126-252126-25+126-256126-260126-262126-26+126-266126-270126-272126-27+126-276126-280126-282126-28+126-286126-290126-292126-29+126-296126-300126-302126-30+126-306126-310126-312126-31+126-316127-000127-002127-00+127-006127-010127-012127-01+127-016127-020127-022127-02+127-026127-030127-032127-03+127-036127-040127-042127-04+127-046127-050127-052127-05+127-056127-060127-062127-06+127-066127-070127-072127-07+127-076127-080127-082127-08+127-086127-090127-092127-09+127-096127-100127-102127-10+127-106127-110127-112127-11+127-116127-120127-122127-12+127-126127-130127-132127-13+127-136127-140127-142127-14+127-146127-150127-152127-15+127-156127-160127-162127-16+127-166127-170127-172127-17+127-176127-180127-182127-18+127-186127-190127-192127-19+127-196127-200127-202127-20+127-206127-210127-212127-21+127-216127-220127-222127-22+127-226127-230127-232127-23+127-236127-240127-242127-24+127-246127-250127-252127-25+127-256127-260127-262127-26+127-266127-270127-272127-27+127-276127-280127-282127-28+127-286127-290127-292127-29+127-296127-300127-302127-30+127-306127-310127-312127-31+127-316128-000128-002128-00+128-006128-010128-012128-01+128-016128-020128-022128-02+128-026128-030128-032128-03+128-036128-040128-042128-04+128-046128-050128-052128-05+128-056128-060128-062128-06+128-066128-070128-072128-07+128-076128-080128-082128-08+128-086128-090128-092128-09+128-096128-100128-102128-10+128-106128-110128-112128-11+128-116128-120128-122128-12+128-126128-130128-132128-13+128-136128-140128-142128-14+128-146128-150128-152128-15+128-156128-160128-162128-16+128-166128-170128-172128-17+128-176128-180128-182128-18+128-186128-190128-192128-19+128-196128-200128-202128-20+128-206128-210128-212128-21+128-216128-220128-222128-22+128-226128-230128-232128-23+128-236128-240128-242128-24+128-246128-250128-252128-25+128-256128-260128-262128-26+128-266128-270128-272128-27+128-276128-280128-282128-28+128-286128-290128-292128-29+128-296128-300128-302128-30+128-306128-310128-312128-31+128-316129-000129-002129-00+129-006129-010129-012129-01+129-016129-020129-022129-02+129-026129-030129-032129-03+129-036129-040129-042129-04+129-046129-050129-052129-05+129-056129-060129-062129-06+129-066129-070129-072129-07+129-076129-080129-082129-08+129-086129-090129-092129-09+129-096129-100129-102129-10+129-106129-110129-112129-11+129-116129-120129-122129-12+129-126129-130129-132129-13+129-136129-140129-142129-14+129-146129-150129-152129-15+129-156129-160129-162129-16+129-166129-170129-172129-17+129-176129-180129-182129-18+129-186129-190129-192129-19+129-196129-200129-202129-20+129-206129-210129-212129-21+129-216129-220129-222129-22+129-226129-230129-232129-23+129-236129-240129-242129-24+129-246129-250129-252129-25+129-256129-260129-262129-26+129-266129-270129-272129-27+129-276129-280129-282129-28+129-286129-290129-292129-29+129-296129-300129-302129-30+129-306129-310129-312129-31+129-316130-000130-002130-00+130-006130-010130-012130-01+130-016130-020130-022130-02+130-026130-030130-032130-03+130-036130-040130-042130-04+130-046130-050130-052130-05+130-056130-060130-062130-06+130-066130-070130-072130-07+130-076130-080130-082130-08+130-086130-090130-092130-09+130-096130-100130-102130-10+130-106130-110130-112130-11+130-116130-120130-122130-12+130-126130-130130-132130-13+130-136130-140130-142130-14+130-146130-150130-152130-15+130-156130-160130-162130-16+130-166130-170130-172130-17+130-176130-180130-182130-18+130-186130-190130-192130-19+130-196130-200130-202130-20+130-206130-210130-212130-21+130-216130-220130-222130-22+130-226130-230130-232130-23+130-236130-240130-242130-24+130-246130-250130-252130-25+130-256130-260130-262130-26+130-266130-270130-272130-27+130-276130-280130-282130-28+130-286130-290130-292130-29+130-296130-300130-302130-30+130-306130-310130-312130-31+130-316";
var startIndex = (int)(state.Integer - 90) * (7 * 128) + state.Fractions128 * 7;
if (state.Integer > 99 && state.Integer < 128)
{
calculated.Slice(startIndex, 7).CopyTo(destination);
}
else if (state.Integer > 89 && state.Integer <= 99)
{
calculated.Slice(startIndex + 1, 6).CopyTo(destination);
}
else
{
state.Integer.TryFormat(destination, out _);
BinaryPrimitives.WriteUInt64LittleEndian(MemoryMarshal.AsBytes(destination[^4..]), GetFractions(state.Fractions128));
}
});
}
public override string ToString() => ToString(null, null);
public bool TryFormat(Span<char> destination, out int charsWritten, ReadOnlySpan<char> format = default, IFormatProvider? provider = default)
{
charsWritten = CountDigits(Integer) + 4;
if (destination.Length < charsWritten)
return false;
ReadOnlySpan<char> calculated = "090-000090-002090-00+090-006090-010090-012090-01+090-016090-020090-022090-02+090-026090-030090-032090-03+090-036090-040090-042090-04+090-046090-050090-052090-05+090-056090-060090-062090-06+090-066090-070090-072090-07+090-076090-080090-082090-08+090-086090-090090-092090-09+090-096090-100090-102090-10+090-106090-110090-112090-11+090-116090-120090-122090-12+090-126090-130090-132090-13+090-136090-140090-142090-14+090-146090-150090-152090-15+090-156090-160090-162090-16+090-166090-170090-172090-17+090-176090-180090-182090-18+090-186090-190090-192090-19+090-196090-200090-202090-20+090-206090-210090-212090-21+090-216090-220090-222090-22+090-226090-230090-232090-23+090-236090-240090-242090-24+090-246090-250090-252090-25+090-256090-260090-262090-26+090-266090-270090-272090-27+090-276090-280090-282090-28+090-286090-290090-292090-29+090-296090-300090-302090-30+090-306090-310090-312090-31+090-316091-000091-002091-00+091-006091-010091-012091-01+091-016091-020091-022091-02+091-026091-030091-032091-03+091-036091-040091-042091-04+091-046091-050091-052091-05+091-056091-060091-062091-06+091-066091-070091-072091-07+091-076091-080091-082091-08+091-086091-090091-092091-09+091-096091-100091-102091-10+091-106091-110091-112091-11+091-116091-120091-122091-12+091-126091-130091-132091-13+091-136091-140091-142091-14+091-146091-150091-152091-15+091-156091-160091-162091-16+091-166091-170091-172091-17+091-176091-180091-182091-18+091-186091-190091-192091-19+091-196091-200091-202091-20+091-206091-210091-212091-21+091-216091-220091-222091-22+091-226091-230091-232091-23+091-236091-240091-242091-24+091-246091-250091-252091-25+091-256091-260091-262091-26+091-266091-270091-272091-27+091-276091-280091-282091-28+091-286091-290091-292091-29+091-296091-300091-302091-30+091-306091-310091-312091-31+091-316092-000092-002092-00+092-006092-010092-012092-01+092-016092-020092-022092-02+092-026092-030092-032092-03+092-036092-040092-042092-04+092-046092-050092-052092-05+092-056092-060092-062092-06+092-066092-070092-072092-07+092-076092-080092-082092-08+092-086092-090092-092092-09+092-096092-100092-102092-10+092-106092-110092-112092-11+092-116092-120092-122092-12+092-126092-130092-132092-13+092-136092-140092-142092-14+092-146092-150092-152092-15+092-156092-160092-162092-16+092-166092-170092-172092-17+092-176092-180092-182092-18+092-186092-190092-192092-19+092-196092-200092-202092-20+092-206092-210092-212092-21+092-216092-220092-222092-22+092-226092-230092-232092-23+092-236092-240092-242092-24+092-246092-250092-252092-25+092-256092-260092-262092-26+092-266092-270092-272092-27+092-276092-280092-282092-28+092-286092-290092-292092-29+092-296092-300092-302092-30+092-306092-310092-312092-31+092-316093-000093-002093-00+093-006093-010093-012093-01+093-016093-020093-022093-02+093-026093-030093-032093-03+093-036093-040093-042093-04+093-046093-050093-052093-05+093-056093-060093-062093-06+093-066093-070093-072093-07+093-076093-080093-082093-08+093-086093-090093-092093-09+093-096093-100093-102093-10+093-106093-110093-112093-11+093-116093-120093-122093-12+093-126093-130093-132093-13+093-136093-140093-142093-14+093-146093-150093-152093-15+093-156093-160093-162093-16+093-166093-170093-172093-17+093-176093-180093-182093-18+093-186093-190093-192093-19+093-196093-200093-202093-20+093-206093-210093-212093-21+093-216093-220093-222093-22+093-226093-230093-232093-23+093-236093-240093-242093-24+093-246093-250093-252093-25+093-256093-260093-262093-26+093-266093-270093-272093-27+093-276093-280093-282093-28+093-286093-290093-292093-29+093-296093-300093-302093-30+093-306093-310093-312093-31+093-316094-000094-002094-00+094-006094-010094-012094-01+094-016094-020094-022094-02+094-026094-030094-032094-03+094-036094-040094-042094-04+094-046094-050094-052094-05+094-056094-060094-062094-06+094-066094-070094-072094-07+094-076094-080094-082094-08+094-086094-090094-092094-09+094-096094-100094-102094-10+094-106094-110094-112094-11+094-116094-120094-122094-12+094-126094-130094-132094-13+094-136094-140094-142094-14+094-146094-150094-152094-15+094-156094-160094-162094-16+094-166094-170094-172094-17+094-176094-180094-182094-18+094-186094-190094-192094-19+094-196094-200094-202094-20+094-206094-210094-212094-21+094-216094-220094-222094-22+094-226094-230094-232094-23+094-236094-240094-242094-24+094-246094-250094-252094-25+094-256094-260094-262094-26+094-266094-270094-272094-27+094-276094-280094-282094-28+094-286094-290094-292094-29+094-296094-300094-302094-30+094-306094-310094-312094-31+094-316095-000095-002095-00+095-006095-010095-012095-01+095-016095-020095-022095-02+095-026095-030095-032095-03+095-036095-040095-042095-04+095-046095-050095-052095-05+095-056095-060095-062095-06+095-066095-070095-072095-07+095-076095-080095-082095-08+095-086095-090095-092095-09+095-096095-100095-102095-10+095-106095-110095-112095-11+095-116095-120095-122095-12+095-126095-130095-132095-13+095-136095-140095-142095-14+095-146095-150095-152095-15+095-156095-160095-162095-16+095-166095-170095-172095-17+095-176095-180095-182095-18+095-186095-190095-192095-19+095-196095-200095-202095-20+095-206095-210095-212095-21+095-216095-220095-222095-22+095-226095-230095-232095-23+095-236095-240095-242095-24+095-246095-250095-252095-25+095-256095-260095-262095-26+095-266095-270095-272095-27+095-276095-280095-282095-28+095-286095-290095-292095-29+095-296095-300095-302095-30+095-306095-310095-312095-31+095-316096-000096-002096-00+096-006096-010096-012096-01+096-016096-020096-022096-02+096-026096-030096-032096-03+096-036096-040096-042096-04+096-046096-050096-052096-05+096-056096-060096-062096-06+096-066096-070096-072096-07+096-076096-080096-082096-08+096-086096-090096-092096-09+096-096096-100096-102096-10+096-106096-110096-112096-11+096-116096-120096-122096-12+096-126096-130096-132096-13+096-136096-140096-142096-14+096-146096-150096-152096-15+096-156096-160096-162096-16+096-166096-170096-172096-17+096-176096-180096-182096-18+096-186096-190096-192096-19+096-196096-200096-202096-20+096-206096-210096-212096-21+096-216096-220096-222096-22+096-226096-230096-232096-23+096-236096-240096-242096-24+096-246096-250096-252096-25+096-256096-260096-262096-26+096-266096-270096-272096-27+096-276096-280096-282096-28+096-286096-290096-292096-29+096-296096-300096-302096-30+096-306096-310096-312096-31+096-316097-000097-002097-00+097-006097-010097-012097-01+097-016097-020097-022097-02+097-026097-030097-032097-03+097-036097-040097-042097-04+097-046097-050097-052097-05+097-056097-060097-062097-06+097-066097-070097-072097-07+097-076097-080097-082097-08+097-086097-090097-092097-09+097-096097-100097-102097-10+097-106097-110097-112097-11+097-116097-120097-122097-12+097-126097-130097-132097-13+097-136097-140097-142097-14+097-146097-150097-152097-15+097-156097-160097-162097-16+097-166097-170097-172097-17+097-176097-180097-182097-18+097-186097-190097-192097-19+097-196097-200097-202097-20+097-206097-210097-212097-21+097-216097-220097-222097-22+097-226097-230097-232097-23+097-236097-240097-242097-24+097-246097-250097-252097-25+097-256097-260097-262097-26+097-266097-270097-272097-27+097-276097-280097-282097-28+097-286097-290097-292097-29+097-296097-300097-302097-30+097-306097-310097-312097-31+097-316098-000098-002098-00+098-006098-010098-012098-01+098-016098-020098-022098-02+098-026098-030098-032098-03+098-036098-040098-042098-04+098-046098-050098-052098-05+098-056098-060098-062098-06+098-066098-070098-072098-07+098-076098-080098-082098-08+098-086098-090098-092098-09+098-096098-100098-102098-10+098-106098-110098-112098-11+098-116098-120098-122098-12+098-126098-130098-132098-13+098-136098-140098-142098-14+098-146098-150098-152098-15+098-156098-160098-162098-16+098-166098-170098-172098-17+098-176098-180098-182098-18+098-186098-190098-192098-19+098-196098-200098-202098-20+098-206098-210098-212098-21+098-216098-220098-222098-22+098-226098-230098-232098-23+098-236098-240098-242098-24+098-246098-250098-252098-25+098-256098-260098-262098-26+098-266098-270098-272098-27+098-276098-280098-282098-28+098-286098-290098-292098-29+098-296098-300098-302098-30+098-306098-310098-312098-31+098-316099-000099-002099-00+099-006099-010099-012099-01+099-016099-020099-022099-02+099-026099-030099-032099-03+099-036099-040099-042099-04+099-046099-050099-052099-05+099-056099-060099-062099-06+099-066099-070099-072099-07+099-076099-080099-082099-08+099-086099-090099-092099-09+099-096099-100099-102099-10+099-106099-110099-112099-11+099-116099-120099-122099-12+099-126099-130099-132099-13+099-136099-140099-142099-14+099-146099-150099-152099-15+099-156099-160099-162099-16+099-166099-170099-172099-17+099-176099-180099-182099-18+099-186099-190099-192099-19+099-196099-200099-202099-20+099-206099-210099-212099-21+099-216099-220099-222099-22+099-226099-230099-232099-23+099-236099-240099-242099-24+099-246099-250099-252099-25+099-256099-260099-262099-26+099-266099-270099-272099-27+099-276099-280099-282099-28+099-286099-290099-292099-29+099-296099-300099-302099-30+099-306099-310099-312099-31+099-316100-000100-002100-00+100-006100-010100-012100-01+100-016100-020100-022100-02+100-026100-030100-032100-03+100-036100-040100-042100-04+100-046100-050100-052100-05+100-056100-060100-062100-06+100-066100-070100-072100-07+100-076100-080100-082100-08+100-086100-090100-092100-09+100-096100-100100-102100-10+100-106100-110100-112100-11+100-116100-120100-122100-12+100-126100-130100-132100-13+100-136100-140100-142100-14+100-146100-150100-152100-15+100-156100-160100-162100-16+100-166100-170100-172100-17+100-176100-180100-182100-18+100-186100-190100-192100-19+100-196100-200100-202100-20+100-206100-210100-212100-21+100-216100-220100-222100-22+100-226100-230100-232100-23+100-236100-240100-242100-24+100-246100-250100-252100-25+100-256100-260100-262100-26+100-266100-270100-272100-27+100-276100-280100-282100-28+100-286100-290100-292100-29+100-296100-300100-302100-30+100-306100-310100-312100-31+100-316101-000101-002101-00+101-006101-010101-012101-01+101-016101-020101-022101-02+101-026101-030101-032101-03+101-036101-040101-042101-04+101-046101-050101-052101-05+101-056101-060101-062101-06+101-066101-070101-072101-07+101-076101-080101-082101-08+101-086101-090101-092101-09+101-096101-100101-102101-10+101-106101-110101-112101-11+101-116101-120101-122101-12+101-126101-130101-132101-13+101-136101-140101-142101-14+101-146101-150101-152101-15+101-156101-160101-162101-16+101-166101-170101-172101-17+101-176101-180101-182101-18+101-186101-190101-192101-19+101-196101-200101-202101-20+101-206101-210101-212101-21+101-216101-220101-222101-22+101-226101-230101-232101-23+101-236101-240101-242101-24+101-246101-250101-252101-25+101-256101-260101-262101-26+101-266101-270101-272101-27+101-276101-280101-282101-28+101-286101-290101-292101-29+101-296101-300101-302101-30+101-306101-310101-312101-31+101-316102-000102-002102-00+102-006102-010102-012102-01+102-016102-020102-022102-02+102-026102-030102-032102-03+102-036102-040102-042102-04+102-046102-050102-052102-05+102-056102-060102-062102-06+102-066102-070102-072102-07+102-076102-080102-082102-08+102-086102-090102-092102-09+102-096102-100102-102102-10+102-106102-110102-112102-11+102-116102-120102-122102-12+102-126102-130102-132102-13+102-136102-140102-142102-14+102-146102-150102-152102-15+102-156102-160102-162102-16+102-166102-170102-172102-17+102-176102-180102-182102-18+102-186102-190102-192102-19+102-196102-200102-202102-20+102-206102-210102-212102-21+102-216102-220102-222102-22+102-226102-230102-232102-23+102-236102-240102-242102-24+102-246102-250102-252102-25+102-256102-260102-262102-26+102-266102-270102-272102-27+102-276102-280102-282102-28+102-286102-290102-292102-29+102-296102-300102-302102-30+102-306102-310102-312102-31+102-316103-000103-002103-00+103-006103-010103-012103-01+103-016103-020103-022103-02+103-026103-030103-032103-03+103-036103-040103-042103-04+103-046103-050103-052103-05+103-056103-060103-062103-06+103-066103-070103-072103-07+103-076103-080103-082103-08+103-086103-090103-092103-09+103-096103-100103-102103-10+103-106103-110103-112103-11+103-116103-120103-122103-12+103-126103-130103-132103-13+103-136103-140103-142103-14+103-146103-150103-152103-15+103-156103-160103-162103-16+103-166103-170103-172103-17+103-176103-180103-182103-18+103-186103-190103-192103-19+103-196103-200103-202103-20+103-206103-210103-212103-21+103-216103-220103-222103-22+103-226103-230103-232103-23+103-236103-240103-242103-24+103-246103-250103-252103-25+103-256103-260103-262103-26+103-266103-270103-272103-27+103-276103-280103-282103-28+103-286103-290103-292103-29+103-296103-300103-302103-30+103-306103-310103-312103-31+103-316104-000104-002104-00+104-006104-010104-012104-01+104-016104-020104-022104-02+104-026104-030104-032104-03+104-036104-040104-042104-04+104-046104-050104-052104-05+104-056104-060104-062104-06+104-066104-070104-072104-07+104-076104-080104-082104-08+104-086104-090104-092104-09+104-096104-100104-102104-10+104-106104-110104-112104-11+104-116104-120104-122104-12+104-126104-130104-132104-13+104-136104-140104-142104-14+104-146104-150104-152104-15+104-156104-160104-162104-16+104-166104-170104-172104-17+104-176104-180104-182104-18+104-186104-190104-192104-19+104-196104-200104-202104-20+104-206104-210104-212104-21+104-216104-220104-222104-22+104-226104-230104-232104-23+104-236104-240104-242104-24+104-246104-250104-252104-25+104-256104-260104-262104-26+104-266104-270104-272104-27+104-276104-280104-282104-28+104-286104-290104-292104-29+104-296104-300104-302104-30+104-306104-310104-312104-31+104-316105-000105-002105-00+105-006105-010105-012105-01+105-016105-020105-022105-02+105-026105-030105-032105-03+105-036105-040105-042105-04+105-046105-050105-052105-05+105-056105-060105-062105-06+105-066105-070105-072105-07+105-076105-080105-082105-08+105-086105-090105-092105-09+105-096105-100105-102105-10+105-106105-110105-112105-11+105-116105-120105-122105-12+105-126105-130105-132105-13+105-136105-140105-142105-14+105-146105-150105-152105-15+105-156105-160105-162105-16+105-166105-170105-172105-17+105-176105-180105-182105-18+105-186105-190105-192105-19+105-196105-200105-202105-20+105-206105-210105-212105-21+105-216105-220105-222105-22+105-226105-230105-232105-23+105-236105-240105-242105-24+105-246105-250105-252105-25+105-256105-260105-262105-26+105-266105-270105-272105-27+105-276105-280105-282105-28+105-286105-290105-292105-29+105-296105-300105-302105-30+105-306105-310105-312105-31+105-316106-000106-002106-00+106-006106-010106-012106-01+106-016106-020106-022106-02+106-026106-030106-032106-03+106-036106-040106-042106-04+106-046106-050106-052106-05+106-056106-060106-062106-06+106-066106-070106-072106-07+106-076106-080106-082106-08+106-086106-090106-092106-09+106-096106-100106-102106-10+106-106106-110106-112106-11+106-116106-120106-122106-12+106-126106-130106-132106-13+106-136106-140106-142106-14+106-146106-150106-152106-15+106-156106-160106-162106-16+106-166106-170106-172106-17+106-176106-180106-182106-18+106-186106-190106-192106-19+106-196106-200106-202106-20+106-206106-210106-212106-21+106-216106-220106-222106-22+106-226106-230106-232106-23+106-236106-240106-242106-24+106-246106-250106-252106-25+106-256106-260106-262106-26+106-266106-270106-272106-27+106-276106-280106-282106-28+106-286106-290106-292106-29+106-296106-300106-302106-30+106-306106-310106-312106-31+106-316107-000107-002107-00+107-006107-010107-012107-01+107-016107-020107-022107-02+107-026107-030107-032107-03+107-036107-040107-042107-04+107-046107-050107-052107-05+107-056107-060107-062107-06+107-066107-070107-072107-07+107-076107-080107-082107-08+107-086107-090107-092107-09+107-096107-100107-102107-10+107-106107-110107-112107-11+107-116107-120107-122107-12+107-126107-130107-132107-13+107-136107-140107-142107-14+107-146107-150107-152107-15+107-156107-160107-162107-16+107-166107-170107-172107-17+107-176107-180107-182107-18+107-186107-190107-192107-19+107-196107-200107-202107-20+107-206107-210107-212107-21+107-216107-220107-222107-22+107-226107-230107-232107-23+107-236107-240107-242107-24+107-246107-250107-252107-25+107-256107-260107-262107-26+107-266107-270107-272107-27+107-276107-280107-282107-28+107-286107-290107-292107-29+107-296107-300107-302107-30+107-306107-310107-312107-31+107-316108-000108-002108-00+108-006108-010108-012108-01+108-016108-020108-022108-02+108-026108-030108-032108-03+108-036108-040108-042108-04+108-046108-050108-052108-05+108-056108-060108-062108-06+108-066108-070108-072108-07+108-076108-080108-082108-08+108-086108-090108-092108-09+108-096108-100108-102108-10+108-106108-110108-112108-11+108-116108-120108-122108-12+108-126108-130108-132108-13+108-136108-140108-142108-14+108-146108-150108-152108-15+108-156108-160108-162108-16+108-166108-170108-172108-17+108-176108-180108-182108-18+108-186108-190108-192108-19+108-196108-200108-202108-20+108-206108-210108-212108-21+108-216108-220108-222108-22+108-226108-230108-232108-23+108-236108-240108-242108-24+108-246108-250108-252108-25+108-256108-260108-262108-26+108-266108-270108-272108-27+108-276108-280108-282108-28+108-286108-290108-292108-29+108-296108-300108-302108-30+108-306108-310108-312108-31+108-316109-000109-002109-00+109-006109-010109-012109-01+109-016109-020109-022109-02+109-026109-030109-032109-03+109-036109-040109-042109-04+109-046109-050109-052109-05+109-056109-060109-062109-06+109-066109-070109-072109-07+109-076109-080109-082109-08+109-086109-090109-092109-09+109-096109-100109-102109-10+109-106109-110109-112109-11+109-116109-120109-122109-12+109-126109-130109-132109-13+109-136109-140109-142109-14+109-146109-150109-152109-15+109-156109-160109-162109-16+109-166109-170109-172109-17+109-176109-180109-182109-18+109-186109-190109-192109-19+109-196109-200109-202109-20+109-206109-210109-212109-21+109-216109-220109-222109-22+109-226109-230109-232109-23+109-236109-240109-242109-24+109-246109-250109-252109-25+109-256109-260109-262109-26+109-266109-270109-272109-27+109-276109-280109-282109-28+109-286109-290109-292109-29+109-296109-300109-302109-30+109-306109-310109-312109-31+109-316110-000110-002110-00+110-006110-010110-012110-01+110-016110-020110-022110-02+110-026110-030110-032110-03+110-036110-040110-042110-04+110-046110-050110-052110-05+110-056110-060110-062110-06+110-066110-070110-072110-07+110-076110-080110-082110-08+110-086110-090110-092110-09+110-096110-100110-102110-10+110-106110-110110-112110-11+110-116110-120110-122110-12+110-126110-130110-132110-13+110-136110-140110-142110-14+110-146110-150110-152110-15+110-156110-160110-162110-16+110-166110-170110-172110-17+110-176110-180110-182110-18+110-186110-190110-192110-19+110-196110-200110-202110-20+110-206110-210110-212110-21+110-216110-220110-222110-22+110-226110-230110-232110-23+110-236110-240110-242110-24+110-246110-250110-252110-25+110-256110-260110-262110-26+110-266110-270110-272110-27+110-276110-280110-282110-28+110-286110-290110-292110-29+110-296110-300110-302110-30+110-306110-310110-312110-31+110-316111-000111-002111-00+111-006111-010111-012111-01+111-016111-020111-022111-02+111-026111-030111-032111-03+111-036111-040111-042111-04+111-046111-050111-052111-05+111-056111-060111-062111-06+111-066111-070111-072111-07+111-076111-080111-082111-08+111-086111-090111-092111-09+111-096111-100111-102111-10+111-106111-110111-112111-11+111-116111-120111-122111-12+111-126111-130111-132111-13+111-136111-140111-142111-14+111-146111-150111-152111-15+111-156111-160111-162111-16+111-166111-170111-172111-17+111-176111-180111-182111-18+111-186111-190111-192111-19+111-196111-200111-202111-20+111-206111-210111-212111-21+111-216111-220111-222111-22+111-226111-230111-232111-23+111-236111-240111-242111-24+111-246111-250111-252111-25+111-256111-260111-262111-26+111-266111-270111-272111-27+111-276111-280111-282111-28+111-286111-290111-292111-29+111-296111-300111-302111-30+111-306111-310111-312111-31+111-316112-000112-002112-00+112-006112-010112-012112-01+112-016112-020112-022112-02+112-026112-030112-032112-03+112-036112-040112-042112-04+112-046112-050112-052112-05+112-056112-060112-062112-06+112-066112-070112-072112-07+112-076112-080112-082112-08+112-086112-090112-092112-09+112-096112-100112-102112-10+112-106112-110112-112112-11+112-116112-120112-122112-12+112-126112-130112-132112-13+112-136112-140112-142112-14+112-146112-150112-152112-15+112-156112-160112-162112-16+112-166112-170112-172112-17+112-176112-180112-182112-18+112-186112-190112-192112-19+112-196112-200112-202112-20+112-206112-210112-212112-21+112-216112-220112-222112-22+112-226112-230112-232112-23+112-236112-240112-242112-24+112-246112-250112-252112-25+112-256112-260112-262112-26+112-266112-270112-272112-27+112-276112-280112-282112-28+112-286112-290112-292112-29+112-296112-300112-302112-30+112-306112-310112-312112-31+112-316113-000113-002113-00+113-006113-010113-012113-01+113-016113-020113-022113-02+113-026113-030113-032113-03+113-036113-040113-042113-04+113-046113-050113-052113-05+113-056113-060113-062113-06+113-066113-070113-072113-07+113-076113-080113-082113-08+113-086113-090113-092113-09+113-096113-100113-102113-10+113-106113-110113-112113-11+113-116113-120113-122113-12+113-126113-130113-132113-13+113-136113-140113-142113-14+113-146113-150113-152113-15+113-156113-160113-162113-16+113-166113-170113-172113-17+113-176113-180113-182113-18+113-186113-190113-192113-19+113-196113-200113-202113-20+113-206113-210113-212113-21+113-216113-220113-222113-22+113-226113-230113-232113-23+113-236113-240113-242113-24+113-246113-250113-252113-25+113-256113-260113-262113-26+113-266113-270113-272113-27+113-276113-280113-282113-28+113-286113-290113-292113-29+113-296113-300113-302113-30+113-306113-310113-312113-31+113-316114-000114-002114-00+114-006114-010114-012114-01+114-016114-020114-022114-02+114-026114-030114-032114-03+114-036114-040114-042114-04+114-046114-050114-052114-05+114-056114-060114-062114-06+114-066114-070114-072114-07+114-076114-080114-082114-08+114-086114-090114-092114-09+114-096114-100114-102114-10+114-106114-110114-112114-11+114-116114-120114-122114-12+114-126114-130114-132114-13+114-136114-140114-142114-14+114-146114-150114-152114-15+114-156114-160114-162114-16+114-166114-170114-172114-17+114-176114-180114-182114-18+114-186114-190114-192114-19+114-196114-200114-202114-20+114-206114-210114-212114-21+114-216114-220114-222114-22+114-226114-230114-232114-23+114-236114-240114-242114-24+114-246114-250114-252114-25+114-256114-260114-262114-26+114-266114-270114-272114-27+114-276114-280114-282114-28+114-286114-290114-292114-29+114-296114-300114-302114-30+114-306114-310114-312114-31+114-316115-000115-002115-00+115-006115-010115-012115-01+115-016115-020115-022115-02+115-026115-030115-032115-03+115-036115-040115-042115-04+115-046115-050115-052115-05+115-056115-060115-062115-06+115-066115-070115-072115-07+115-076115-080115-082115-08+115-086115-090115-092115-09+115-096115-100115-102115-10+115-106115-110115-112115-11+115-116115-120115-122115-12+115-126115-130115-132115-13+115-136115-140115-142115-14+115-146115-150115-152115-15+115-156115-160115-162115-16+115-166115-170115-172115-17+115-176115-180115-182115-18+115-186115-190115-192115-19+115-196115-200115-202115-20+115-206115-210115-212115-21+115-216115-220115-222115-22+115-226115-230115-232115-23+115-236115-240115-242115-24+115-246115-250115-252115-25+115-256115-260115-262115-26+115-266115-270115-272115-27+115-276115-280115-282115-28+115-286115-290115-292115-29+115-296115-300115-302115-30+115-306115-310115-312115-31+115-316116-000116-002116-00+116-006116-010116-012116-01+116-016116-020116-022116-02+116-026116-030116-032116-03+116-036116-040116-042116-04+116-046116-050116-052116-05+116-056116-060116-062116-06+116-066116-070116-072116-07+116-076116-080116-082116-08+116-086116-090116-092116-09+116-096116-100116-102116-10+116-106116-110116-112116-11+116-116116-120116-122116-12+116-126116-130116-132116-13+116-136116-140116-142116-14+116-146116-150116-152116-15+116-156116-160116-162116-16+116-166116-170116-172116-17+116-176116-180116-182116-18+116-186116-190116-192116-19+116-196116-200116-202116-20+116-206116-210116-212116-21+116-216116-220116-222116-22+116-226116-230116-232116-23+116-236116-240116-242116-24+116-246116-250116-252116-25+116-256116-260116-262116-26+116-266116-270116-272116-27+116-276116-280116-282116-28+116-286116-290116-292116-29+116-296116-300116-302116-30+116-306116-310116-312116-31+116-316117-000117-002117-00+117-006117-010117-012117-01+117-016117-020117-022117-02+117-026117-030117-032117-03+117-036117-040117-042117-04+117-046117-050117-052117-05+117-056117-060117-062117-06+117-066117-070117-072117-07+117-076117-080117-082117-08+117-086117-090117-092117-09+117-096117-100117-102117-10+117-106117-110117-112117-11+117-116117-120117-122117-12+117-126117-130117-132117-13+117-136117-140117-142117-14+117-146117-150117-152117-15+117-156117-160117-162117-16+117-166117-170117-172117-17+117-176117-180117-182117-18+117-186117-190117-192117-19+117-196117-200117-202117-20+117-206117-210117-212117-21+117-216117-220117-222117-22+117-226117-230117-232117-23+117-236117-240117-242117-24+117-246117-250117-252117-25+117-256117-260117-262117-26+117-266117-270117-272117-27+117-276117-280117-282117-28+117-286117-290117-292117-29+117-296117-300117-302117-30+117-306117-310117-312117-31+117-316118-000118-002118-00+118-006118-010118-012118-01+118-016118-020118-022118-02+118-026118-030118-032118-03+118-036118-040118-042118-04+118-046118-050118-052118-05+118-056118-060118-062118-06+118-066118-070118-072118-07+118-076118-080118-082118-08+118-086118-090118-092118-09+118-096118-100118-102118-10+118-106118-110118-112118-11+118-116118-120118-122118-12+118-126118-130118-132118-13+118-136118-140118-142118-14+118-146118-150118-152118-15+118-156118-160118-162118-16+118-166118-170118-172118-17+118-176118-180118-182118-18+118-186118-190118-192118-19+118-196118-200118-202118-20+118-206118-210118-212118-21+118-216118-220118-222118-22+118-226118-230118-232118-23+118-236118-240118-242118-24+118-246118-250118-252118-25+118-256118-260118-262118-26+118-266118-270118-272118-27+118-276118-280118-282118-28+118-286118-290118-292118-29+118-296118-300118-302118-30+118-306118-310118-312118-31+118-316119-000119-002119-00+119-006119-010119-012119-01+119-016119-020119-022119-02+119-026119-030119-032119-03+119-036119-040119-042119-04+119-046119-050119-052119-05+119-056119-060119-062119-06+119-066119-070119-072119-07+119-076119-080119-082119-08+119-086119-090119-092119-09+119-096119-100119-102119-10+119-106119-110119-112119-11+119-116119-120119-122119-12+119-126119-130119-132119-13+119-136119-140119-142119-14+119-146119-150119-152119-15+119-156119-160119-162119-16+119-166119-170119-172119-17+119-176119-180119-182119-18+119-186119-190119-192119-19+119-196119-200119-202119-20+119-206119-210119-212119-21+119-216119-220119-222119-22+119-226119-230119-232119-23+119-236119-240119-242119-24+119-246119-250119-252119-25+119-256119-260119-262119-26+119-266119-270119-272119-27+119-276119-280119-282119-28+119-286119-290119-292119-29+119-296119-300119-302119-30+119-306119-310119-312119-31+119-316120-000120-002120-00+120-006120-010120-012120-01+120-016120-020120-022120-02+120-026120-030120-032120-03+120-036120-040120-042120-04+120-046120-050120-052120-05+120-056120-060120-062120-06+120-066120-070120-072120-07+120-076120-080120-082120-08+120-086120-090120-092120-09+120-096120-100120-102120-10+120-106120-110120-112120-11+120-116120-120120-122120-12+120-126120-130120-132120-13+120-136120-140120-142120-14+120-146120-150120-152120-15+120-156120-160120-162120-16+120-166120-170120-172120-17+120-176120-180120-182120-18+120-186120-190120-192120-19+120-196120-200120-202120-20+120-206120-210120-212120-21+120-216120-220120-222120-22+120-226120-230120-232120-23+120-236120-240120-242120-24+120-246120-250120-252120-25+120-256120-260120-262120-26+120-266120-270120-272120-27+120-276120-280120-282120-28+120-286120-290120-292120-29+120-296120-300120-302120-30+120-306120-310120-312120-31+120-316121-000121-002121-00+121-006121-010121-012121-01+121-016121-020121-022121-02+121-026121-030121-032121-03+121-036121-040121-042121-04+121-046121-050121-052121-05+121-056121-060121-062121-06+121-066121-070121-072121-07+121-076121-080121-082121-08+121-086121-090121-092121-09+121-096121-100121-102121-10+121-106121-110121-112121-11+121-116121-120121-122121-12+121-126121-130121-132121-13+121-136121-140121-142121-14+121-146121-150121-152121-15+121-156121-160121-162121-16+121-166121-170121-172121-17+121-176121-180121-182121-18+121-186121-190121-192121-19+121-196121-200121-202121-20+121-206121-210121-212121-21+121-216121-220121-222121-22+121-226121-230121-232121-23+121-236121-240121-242121-24+121-246121-250121-252121-25+121-256121-260121-262121-26+121-266121-270121-272121-27+121-276121-280121-282121-28+121-286121-290121-292121-29+121-296121-300121-302121-30+121-306121-310121-312121-31+121-316122-000122-002122-00+122-006122-010122-012122-01+122-016122-020122-022122-02+122-026122-030122-032122-03+122-036122-040122-042122-04+122-046122-050122-052122-05+122-056122-060122-062122-06+122-066122-070122-072122-07+122-076122-080122-082122-08+122-086122-090122-092122-09+122-096122-100122-102122-10+122-106122-110122-112122-11+122-116122-120122-122122-12+122-126122-130122-132122-13+122-136122-140122-142122-14+122-146122-150122-152122-15+122-156122-160122-162122-16+122-166122-170122-172122-17+122-176122-180122-182122-18+122-186122-190122-192122-19+122-196122-200122-202122-20+122-206122-210122-212122-21+122-216122-220122-222122-22+122-226122-230122-232122-23+122-236122-240122-242122-24+122-246122-250122-252122-25+122-256122-260122-262122-26+122-266122-270122-272122-27+122-276122-280122-282122-28+122-286122-290122-292122-29+122-296122-300122-302122-30+122-306122-310122-312122-31+122-316123-000123-002123-00+123-006123-010123-012123-01+123-016123-020123-022123-02+123-026123-030123-032123-03+123-036123-040123-042123-04+123-046123-050123-052123-05+123-056123-060123-062123-06+123-066123-070123-072123-07+123-076123-080123-082123-08+123-086123-090123-092123-09+123-096123-100123-102123-10+123-106123-110123-112123-11+123-116123-120123-122123-12+123-126123-130123-132123-13+123-136123-140123-142123-14+123-146123-150123-152123-15+123-156123-160123-162123-16+123-166123-170123-172123-17+123-176123-180123-182123-18+123-186123-190123-192123-19+123-196123-200123-202123-20+123-206123-210123-212123-21+123-216123-220123-222123-22+123-226123-230123-232123-23+123-236123-240123-242123-24+123-246123-250123-252123-25+123-256123-260123-262123-26+123-266123-270123-272123-27+123-276123-280123-282123-28+123-286123-290123-292123-29+123-296123-300123-302123-30+123-306123-310123-312123-31+123-316124-000124-002124-00+124-006124-010124-012124-01+124-016124-020124-022124-02+124-026124-030124-032124-03+124-036124-040124-042124-04+124-046124-050124-052124-05+124-056124-060124-062124-06+124-066124-070124-072124-07+124-076124-080124-082124-08+124-086124-090124-092124-09+124-096124-100124-102124-10+124-106124-110124-112124-11+124-116124-120124-122124-12+124-126124-130124-132124-13+124-136124-140124-142124-14+124-146124-150124-152124-15+124-156124-160124-162124-16+124-166124-170124-172124-17+124-176124-180124-182124-18+124-186124-190124-192124-19+124-196124-200124-202124-20+124-206124-210124-212124-21+124-216124-220124-222124-22+124-226124-230124-232124-23+124-236124-240124-242124-24+124-246124-250124-252124-25+124-256124-260124-262124-26+124-266124-270124-272124-27+124-276124-280124-282124-28+124-286124-290124-292124-29+124-296124-300124-302124-30+124-306124-310124-312124-31+124-316125-000125-002125-00+125-006125-010125-012125-01+125-016125-020125-022125-02+125-026125-030125-032125-03+125-036125-040125-042125-04+125-046125-050125-052125-05+125-056125-060125-062125-06+125-066125-070125-072125-07+125-076125-080125-082125-08+125-086125-090125-092125-09+125-096125-100125-102125-10+125-106125-110125-112125-11+125-116125-120125-122125-12+125-126125-130125-132125-13+125-136125-140125-142125-14+125-146125-150125-152125-15+125-156125-160125-162125-16+125-166125-170125-172125-17+125-176125-180125-182125-18+125-186125-190125-192125-19+125-196125-200125-202125-20+125-206125-210125-212125-21+125-216125-220125-222125-22+125-226125-230125-232125-23+125-236125-240125-242125-24+125-246125-250125-252125-25+125-256125-260125-262125-26+125-266125-270125-272125-27+125-276125-280125-282125-28+125-286125-290125-292125-29+125-296125-300125-302125-30+125-306125-310125-312125-31+125-316126-000126-002126-00+126-006126-010126-012126-01+126-016126-020126-022126-02+126-026126-030126-032126-03+126-036126-040126-042126-04+126-046126-050126-052126-05+126-056126-060126-062126-06+126-066126-070126-072126-07+126-076126-080126-082126-08+126-086126-090126-092126-09+126-096126-100126-102126-10+126-106126-110126-112126-11+126-116126-120126-122126-12+126-126126-130126-132126-13+126-136126-140126-142126-14+126-146126-150126-152126-15+126-156126-160126-162126-16+126-166126-170126-172126-17+126-176126-180126-182126-18+126-186126-190126-192126-19+126-196126-200126-202126-20+126-206126-210126-212126-21+126-216126-220126-222126-22+126-226126-230126-232126-23+126-236126-240126-242126-24+126-246126-250126-252126-25+126-256126-260126-262126-26+126-266126-270126-272126-27+126-276126-280126-282126-28+126-286126-290126-292126-29+126-296126-300126-302126-30+126-306126-310126-312126-31+126-316127-000127-002127-00+127-006127-010127-012127-01+127-016127-020127-022127-02+127-026127-030127-032127-03+127-036127-040127-042127-04+127-046127-050127-052127-05+127-056127-060127-062127-06+127-066127-070127-072127-07+127-076127-080127-082127-08+127-086127-090127-092127-09+127-096127-100127-102127-10+127-106127-110127-112127-11+127-116127-120127-122127-12+127-126127-130127-132127-13+127-136127-140127-142127-14+127-146127-150127-152127-15+127-156127-160127-162127-16+127-166127-170127-172127-17+127-176127-180127-182127-18+127-186127-190127-192127-19+127-196127-200127-202127-20+127-206127-210127-212127-21+127-216127-220127-222127-22+127-226127-230127-232127-23+127-236127-240127-242127-24+127-246127-250127-252127-25+127-256127-260127-262127-26+127-266127-270127-272127-27+127-276127-280127-282127-28+127-286127-290127-292127-29+127-296127-300127-302127-30+127-306127-310127-312127-31+127-316128-000128-002128-00+128-006128-010128-012128-01+128-016128-020128-022128-02+128-026128-030128-032128-03+128-036128-040128-042128-04+128-046128-050128-052128-05+128-056128-060128-062128-06+128-066128-070128-072128-07+128-076128-080128-082128-08+128-086128-090128-092128-09+128-096128-100128-102128-10+128-106128-110128-112128-11+128-116128-120128-122128-12+128-126128-130128-132128-13+128-136128-140128-142128-14+128-146128-150128-152128-15+128-156128-160128-162128-16+128-166128-170128-172128-17+128-176128-180128-182128-18+128-186128-190128-192128-19+128-196128-200128-202128-20+128-206128-210128-212128-21+128-216128-220128-222128-22+128-226128-230128-232128-23+128-236128-240128-242128-24+128-246128-250128-252128-25+128-256128-260128-262128-26+128-266128-270128-272128-27+128-276128-280128-282128-28+128-286128-290128-292128-29+128-296128-300128-302128-30+128-306128-310128-312128-31+128-316129-000129-002129-00+129-006129-010129-012129-01+129-016129-020129-022129-02+129-026129-030129-032129-03+129-036129-040129-042129-04+129-046129-050129-052129-05+129-056129-060129-062129-06+129-066129-070129-072129-07+129-076129-080129-082129-08+129-086129-090129-092129-09+129-096129-100129-102129-10+129-106129-110129-112129-11+129-116129-120129-122129-12+129-126129-130129-132129-13+129-136129-140129-142129-14+129-146129-150129-152129-15+129-156129-160129-162129-16+129-166129-170129-172129-17+129-176129-180129-182129-18+129-186129-190129-192129-19+129-196129-200129-202129-20+129-206129-210129-212129-21+129-216129-220129-222129-22+129-226129-230129-232129-23+129-236129-240129-242129-24+129-246129-250129-252129-25+129-256129-260129-262129-26+129-266129-270129-272129-27+129-276129-280129-282129-28+129-286129-290129-292129-29+129-296129-300129-302129-30+129-306129-310129-312129-31+129-316130-000130-002130-00+130-006130-010130-012130-01+130-016130-020130-022130-02+130-026130-030130-032130-03+130-036130-040130-042130-04+130-046130-050130-052130-05+130-056130-060130-062130-06+130-066130-070130-072130-07+130-076130-080130-082130-08+130-086130-090130-092130-09+130-096130-100130-102130-10+130-106130-110130-112130-11+130-116130-120130-122130-12+130-126130-130130-132130-13+130-136130-140130-142130-14+130-146130-150130-152130-15+130-156130-160130-162130-16+130-166130-170130-172130-17+130-176130-180130-182130-18+130-186130-190130-192130-19+130-196130-200130-202130-20+130-206130-210130-212130-21+130-216130-220130-222130-22+130-226130-230130-232130-23+130-236130-240130-242130-24+130-246130-250130-252130-25+130-256130-260130-262130-26+130-266130-270130-272130-27+130-276130-280130-282130-28+130-286130-290130-292130-29+130-296130-300130-302130-30+130-306130-310130-312130-31+130-316";
var startIndex = (int)(Integer - 90) * (7 * 128) + Fractions128 * 7;
if (Integer > 99 && Integer < 128)
{
calculated.Slice(startIndex, 7).CopyTo(destination);
}
else if (Integer > 89 && Integer <= 99)
{
calculated.Slice(startIndex + 1, 6).CopyTo(destination);
}
else
{
Integer.TryFormat(destination, out _);
BinaryPrimitives.WriteUInt64LittleEndian(MemoryMarshal.AsBytes(destination[^4..]), GetFractions(Fractions128));
}
return true;
}
private static ulong GetFractions(int index)
{
ReadOnlySpan<ulong> table = new ulong[] { 0x3000300030002d, 0x3200300030002d, 0x2b00300030002d, 0x3600300030002d, 0x3000310030002d, 0x3200310030002d, 0x2b00310030002d, 0x3600310030002d, 0x3000320030002d, 0x3200320030002d, 0x2b00320030002d, 0x3600320030002d, 0x3000330030002d, 0x3200330030002d, 0x2b00330030002d, 0x3600330030002d, 0x3000340030002d, 0x3200340030002d, 0x2b00340030002d, 0x3600340030002d, 0x3000350030002d, 0x3200350030002d, 0x2b00350030002d, 0x3600350030002d, 0x3000360030002d, 0x3200360030002d, 0x2b00360030002d, 0x3600360030002d, 0x3000370030002d, 0x3200370030002d, 0x2b00370030002d, 0x3600370030002d, 0x3000380030002d, 0x3200380030002d, 0x2b00380030002d, 0x3600380030002d, 0x3000390030002d, 0x3200390030002d, 0x2b00390030002d, 0x3600390030002d, 0x3000300031002d, 0x3200300031002d, 0x2b00300031002d, 0x3600300031002d, 0x3000310031002d, 0x3200310031002d, 0x2b00310031002d, 0x3600310031002d, 0x3000320031002d, 0x3200320031002d, 0x2b00320031002d, 0x3600320031002d, 0x3000330031002d, 0x3200330031002d, 0x2b00330031002d, 0x3600330031002d, 0x3000340031002d, 0x3200340031002d, 0x2b00340031002d, 0x3600340031002d, 0x3000350031002d, 0x3200350031002d, 0x2b00350031002d, 0x3600350031002d, 0x3000360031002d, 0x3200360031002d, 0x2b00360031002d, 0x3600360031002d, 0x3000370031002d, 0x3200370031002d, 0x2b00370031002d, 0x3600370031002d, 0x3000380031002d, 0x3200380031002d, 0x2b00380031002d, 0x3600380031002d, 0x3000390031002d, 0x3200390031002d, 0x2b00390031002d, 0x3600390031002d, 0x3000300032002d, 0x3200300032002d, 0x2b00300032002d, 0x3600300032002d, 0x3000310032002d, 0x3200310032002d, 0x2b00310032002d, 0x3600310032002d, 0x3000320032002d, 0x3200320032002d, 0x2b00320032002d, 0x3600320032002d, 0x3000330032002d, 0x3200330032002d, 0x2b00330032002d, 0x3600330032002d, 0x3000340032002d, 0x3200340032002d, 0x2b00340032002d, 0x3600340032002d, 0x3000350032002d, 0x3200350032002d, 0x2b00350032002d, 0x3600350032002d, 0x3000360032002d, 0x3200360032002d, 0x2b00360032002d, 0x3600360032002d, 0x3000370032002d, 0x3200370032002d, 0x2b00370032002d, 0x3600370032002d, 0x3000380032002d, 0x3200380032002d, 0x2b00380032002d, 0x3600380032002d, 0x3000390032002d, 0x3200390032002d, 0x2b00390032002d, 0x3600390032002d, 0x3000300033002d, 0x3200300033002d, 0x2b00300033002d, 0x3600300033002d, 0x3000310033002d, 0x3200310033002d, 0x2b00310033002d, 0x3600310033002d };
return table[index];
}
private static int CountDigits(uint value)
{
// Algorithm based on https://lemire.me/blog/2021/06/03/computing-the-number-of-digits-of-an-integer-even-faster.
ReadOnlySpan<long> table = new long[]
{
4294967296,
8589934582,
8589934582,
8589934582,
12884901788,
12884901788,
12884901788,
17179868184,
17179868184,
17179868184,
21474826480,
21474826480,
21474826480,
21474826480,
25769703776,
25769703776,
25769703776,
30063771072,
30063771072,
30063771072,
34349738368,
34349738368,
34349738368,
34349738368,
38554705664,
38554705664,
38554705664,
41949672960,
41949672960,
41949672960,
42949672960,
42949672960,
};
long tableValue = Unsafe.Add(ref MemoryMarshal.GetReference(table), uint.Log2(value));
return (int)((value + tableValue) >> 32);
}
}
public record struct FastFractional : ISpanFormattable
{
private byte _fractions128;
public required uint Integer { get; init; }
public required byte Fractions128
{
get => _fractions128;
init
{
if (value > 128)
throw new ArgumentOutOfRangeException();
_fractions128 = value;
}
}
public double AsDouble() => Integer + (Fractions128 / 128.0);
public string ToString(string? format, IFormatProvider? formatProvider)
{
return string.Create(CountDigits(Integer) + 4, ((Integer, Fractions128)), static (destination, state) =>
{
if (state.Integer > 89 && state.Integer < 128)
BinaryPrimitives.WriteUInt64LittleEndian(MemoryMarshal.AsBytes(destination), GetInteger((int)state.Integer));
else
state.Integer.TryFormat(destination, out _);
BinaryPrimitives.WriteUInt64LittleEndian(MemoryMarshal.AsBytes(destination[^4..]), GetFractions(state.Fractions128));
});
}
public override string ToString() => ToString(null, null);
public bool TryFormat(Span<char> destination, out int charsWritten, ReadOnlySpan<char> format = default, IFormatProvider? provider = default)
{
charsWritten = CountDigits(Integer) + 4;
if (destination.Length < charsWritten)
return false;
if (Integer > 89 && Integer < 128)
BinaryPrimitives.WriteUInt64LittleEndian(MemoryMarshal.AsBytes(destination), GetInteger((int)Integer));
else
Integer.TryFormat(destination, out _);
BinaryPrimitives.WriteUInt64LittleEndian(MemoryMarshal.AsBytes(destination[^4..]), GetFractions(Fractions128));
return true;
}
private static ulong GetInteger(int value)
{
ReadOnlySpan<ulong> table = new ulong[] { 0x20002000300039, 0x20002000310039, 0x20002000320039, 0x20002000330039, 0x20002000340039, 0x20002000350039, 0x20002000360039, 0x20002000370039, 0x20002000380039, 0x20002000390039, 0x20003000300031, 0x20003100300031, 0x20003200300031, 0x20003300300031, 0x20003400300031, 0x20003500300031, 0x20003600300031, 0x20003700300031, 0x20003800300031, 0x20003900300031, 0x20003000310031, 0x20003100310031, 0x20003200310031, 0x20003300310031, 0x20003400310031, 0x20003500310031, 0x20003600310031, 0x20003700310031, 0x20003800310031, 0x20003900310031, 0x20003000320031, 0x20003100320031, 0x20003200320031, 0x20003300320031, 0x20003400320031, 0x20003500320031, 0x20003600320031, 0x20003700320031, 0x20003800320031, 0x20003900320031, 0x20003000330031 };
return table[value - 90];
}
private static ulong GetFractions(int index)
{
ReadOnlySpan<ulong> table = new ulong[] { 0x3000300030002d, 0x3200300030002d, 0x2b00300030002d, 0x3600300030002d, 0x3000310030002d, 0x3200310030002d, 0x2b00310030002d, 0x3600310030002d, 0x3000320030002d, 0x3200320030002d, 0x2b00320030002d, 0x3600320030002d, 0x3000330030002d, 0x3200330030002d, 0x2b00330030002d, 0x3600330030002d, 0x3000340030002d, 0x3200340030002d, 0x2b00340030002d, 0x3600340030002d, 0x3000350030002d, 0x3200350030002d, 0x2b00350030002d, 0x3600350030002d, 0x3000360030002d, 0x3200360030002d, 0x2b00360030002d, 0x3600360030002d, 0x3000370030002d, 0x3200370030002d, 0x2b00370030002d, 0x3600370030002d, 0x3000380030002d, 0x3200380030002d, 0x2b00380030002d, 0x3600380030002d, 0x3000390030002d, 0x3200390030002d, 0x2b00390030002d, 0x3600390030002d, 0x3000300031002d, 0x3200300031002d, 0x2b00300031002d, 0x3600300031002d, 0x3000310031002d, 0x3200310031002d, 0x2b00310031002d, 0x3600310031002d, 0x3000320031002d, 0x3200320031002d, 0x2b00320031002d, 0x3600320031002d, 0x3000330031002d, 0x3200330031002d, 0x2b00330031002d, 0x3600330031002d, 0x3000340031002d, 0x3200340031002d, 0x2b00340031002d, 0x3600340031002d, 0x3000350031002d, 0x3200350031002d, 0x2b00350031002d, 0x3600350031002d, 0x3000360031002d, 0x3200360031002d, 0x2b00360031002d, 0x3600360031002d, 0x3000370031002d, 0x3200370031002d, 0x2b00370031002d, 0x3600370031002d, 0x3000380031002d, 0x3200380031002d, 0x2b00380031002d, 0x3600380031002d, 0x3000390031002d, 0x3200390031002d, 0x2b00390031002d, 0x3600390031002d, 0x3000300032002d, 0x3200300032002d, 0x2b00300032002d, 0x3600300032002d, 0x3000310032002d, 0x3200310032002d, 0x2b00310032002d, 0x3600310032002d, 0x3000320032002d, 0x3200320032002d, 0x2b00320032002d, 0x3600320032002d, 0x3000330032002d, 0x3200330032002d, 0x2b00330032002d, 0x3600330032002d, 0x3000340032002d, 0x3200340032002d, 0x2b00340032002d, 0x3600340032002d, 0x3000350032002d, 0x3200350032002d, 0x2b00350032002d, 0x3600350032002d, 0x3000360032002d, 0x3200360032002d, 0x2b00360032002d, 0x3600360032002d, 0x3000370032002d, 0x3200370032002d, 0x2b00370032002d, 0x3600370032002d, 0x3000380032002d, 0x3200380032002d, 0x2b00380032002d, 0x3600380032002d, 0x3000390032002d, 0x3200390032002d, 0x2b00390032002d, 0x3600390032002d, 0x3000300033002d, 0x3200300033002d, 0x2b00300033002d, 0x3600300033002d, 0x3000310033002d, 0x3200310033002d, 0x2b00310033002d, 0x3600310033002d };
return table[index];
}
private static int CountDigits(uint value)
{
// Algorithm based on https://lemire.me/blog/2021/06/03/computing-the-number-of-digits-of-an-integer-even-faster.
ReadOnlySpan<long> table = new long[]
{
4294967296,
8589934582,
8589934582,
8589934582,
12884901788,
12884901788,
12884901788,
17179868184,
17179868184,
17179868184,
21474826480,
21474826480,
21474826480,
21474826480,
25769703776,
25769703776,
25769703776,
30063771072,
30063771072,
30063771072,
34349738368,
34349738368,
34349738368,
34349738368,
38554705664,
38554705664,
38554705664,
41949672960,
41949672960,
41949672960,
42949672960,
42949672960,
};
long tableValue = Unsafe.Add(ref MemoryMarshal.GetReference(table), uint.Log2(value));
return (int)((value + tableValue) >> 32);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment