File tree Expand file tree Collapse file tree 2 files changed +8
-22
lines changed Expand file tree Collapse file tree 2 files changed +8
-22
lines changed Original file line number Diff line number Diff line change 1
- using System ;
1
+ // <copyright file="Bits.cs" company="Sedat Kapanoglu">
2
+ // Copyright (c) 2014-2025 Sedat Kapanoglu
3
+ // Licensed under Apache-2.0 License (see LICENSE.txt file for details)
4
+ // </copyright>
5
+
6
+ using System ;
2
7
3
8
namespace SimpleBase
4
9
{
@@ -36,25 +41,5 @@ internal static ulong PartialBigEndianBytesToUInt64(ReadOnlySpan<byte> bytes)
36
41
}
37
42
return result ;
38
43
}
39
-
40
- /// <summary>
41
- /// Converts a UInt64 to a byte array in big-endian order.
42
- /// </summary>
43
- /// <param name="value">Value to convert.</param>
44
- /// <param name="output">Output buffer.</param>
45
- /// <exception cref="ArgumentException">If the buffer is too small.</exception>
46
- internal static void UInt64ToBigEndianBytes ( ulong value , Span < byte > output )
47
- {
48
- if ( output . Length < sizeof ( ulong ) )
49
- {
50
- throw new ArgumentException ( "Output is too small" , nameof ( output ) ) ;
51
- }
52
- int byteCount = sizeof ( ulong ) ;
53
- for ( int i = byteCount - 1 ; i >= 0 ; i -- )
54
- {
55
- output [ i ] = ( byte ) ( value & 0xFF ) ;
56
- value >>= 8 ;
57
- }
58
- }
59
44
}
60
45
}
Original file line number Diff line number Diff line change 4
4
// </copyright>
5
5
6
6
using System ;
7
+ using System . Buffers . Binary ;
7
8
8
9
namespace SimpleBase ;
9
10
@@ -212,7 +213,7 @@ enum DecodeResult
212
213
}
213
214
pad += ( uint ) value ;
214
215
}
215
- Bits . UInt64ToBigEndianBytes ( pad , output ) ;
216
+ BinaryPrimitives . WriteUInt64BigEndian ( output , pad ) ;
216
217
return ( DecodeResult . Success , null ) ;
217
218
}
218
219
You can’t perform that action at this time.
0 commit comments