forked from Unity-Technologies/com.unity.netcode.gameobjects
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUIntFloat.cs
More file actions
26 lines (22 loc) · 825 Bytes
/
UIntFloat.cs
File metadata and controls
26 lines (22 loc) · 825 Bytes
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
using System.Runtime.InteropServices;
namespace MLAPI.Serialization
{
/// <summary>
/// A struct with a explicit memory layout. The struct has 4 fields. float,uint,double and ulong.
/// Every field has the same starting point in memory. If you insert a float value, it can be extracted as a uint.
/// This is to allow for lockless and garbage free conversion from float to uint and double to ulong.
/// This allows for VarInt encoding and other integer encodings.
/// </summary>
[StructLayout(LayoutKind.Explicit)]
internal struct UIntFloat
{
[FieldOffset(0)]
public float FloatValue;
[FieldOffset(0)]
public uint UIntValue;
[FieldOffset(0)]
public double DoubleValue;
[FieldOffset(0)]
public ulong ULongValue;
}
}