Files
Mapo-IOB-WIN/IOB-UT-NEXT/Objects/Endian.cs
T
2026-05-21 20:05:29 +02:00

39 lines
1012 B
C#

using System;
namespace IOB_UT_NEXT.Objects
{
/// <summary>
/// Gestione Endianness
/// </summary>
public static class Endian
{
#region Public Methods
/// <summary>
/// Scambia MSB/LSB per 16bit
/// </summary>
/// <param name="inValue"></param>
/// <returns></returns>
public static UInt16 SwapUInt16(UInt16 inValue)
{
return (UInt16)(((inValue & 0xff00) >> 8) |
((inValue & 0x00ff) << 8));
}
/// <summary>
/// Scambia MSB/LSB per 32bit
/// </summary>
/// <param name="inValue"></param>
/// <returns></returns>
public static UInt32 SwapUInt32(UInt32 inValue)
{
return ((inValue & 0xff000000) >> 24) |
((inValue & 0x00ff0000) >> 8) |
((inValue & 0x0000ff00) << 8) |
((inValue & 0x000000ff) << 24);
}
#endregion Public Methods
}
}