-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBigEndianBinaryReader.cs
More file actions
42 lines (36 loc) · 1.16 KB
/
BigEndianBinaryReader.cs
File metadata and controls
42 lines (36 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using System.IO;
using System.Text;
namespace VisiMatrix
{
public class BigEndianBinaryReader : BinaryReader
{
public BigEndianBinaryReader(Stream input) : base(input)
{
}
public BigEndianBinaryReader(Stream input, Encoding encoding) : base(input, encoding)
{
}
public BigEndianBinaryReader(Stream input, Encoding encoding, bool leaveOpen) : base(input, encoding, leaveOpen)
{
}
public override ushort ReadUInt16()
{
return (ushort) ((ReadByte() << 8) + ReadByte());
}
public override uint ReadUInt32()
{
return (uint) ((ReadByte() << 24) + (ReadByte() << 16) + (ReadByte() << 8) + ReadByte());
}
public override ulong ReadUInt64()
{
return ((ulong) ReadByte() << 56) +
((ulong) ReadByte() << 48) +
((ulong) ReadByte() << 40) +
((ulong) ReadByte() << 32) +
((ulong) ReadByte() << 24) +
((ulong) ReadByte() << 16) +
((ulong) ReadByte() << 8) +
ReadByte();
}
}
}