You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Ryu, implemented by C#, a high-performance algorithm for converting floats to strings.
2023-09-21 RyuCsharp update descriptions:
To avoid managed memory fragmentation, the implementation was changed from pointers to references. (The difference between pointer and reference is that the former is an unmanaged pointer and the latter is a managed pointer.)
Inherit the open source license of the parent project to make it easier for everyone to use.
{// Arraychar[]charArray=newchar[32];// Need to ensure that the memory size is sufficient.varwrittenLength=Ryu.d2s_buffered_n(3.1415926D,refcharArray[0]);Console.WriteLine(newstring(charArray,0,writtenLength));// Output: 3.1415926E0}{// SpanSpan<char>charSpan=(newchar[32]).AsSpan();varwrittenLength=Ryu.d2s_buffered_n(3.1415926D,refcharSpan[0]);Console.WriteLine(charSpan.Slice(0,writtenLength).ToString());// Output: 3.1415926E0}{// Pointerchar*pChars=stackallocchar[32];Ryu.d2s_buffered(3.1415926D,ref*pChars);Console.WriteLine(newstring(pChars));// Output: 3.1415926E0}