Mega Code Archive

 
Categories / C# / Internationalization
 

Flip Endian

using System; using System.Collections.Generic; using System.Text; public static class Utility {     public static Int16 FlipEndian(Int16 value)     {         short b1 = (short)((value & 0xFF) << 8);         short b2 = (short)((value >> 8) & 0xFF);         return (short)(b1 | b2);     }     public static Int32 FlipEndian(Int32 value)     {         int s1 = (FlipEndian((short)value) & 0xFFFF) << 0x10;         int s2 = FlipEndian((short)(value >> 0x10)) & 0xFFFF;         return s1 | s2;     }     public static Int64 FlipEndian(Int64 value)     {         long i1 = (FlipEndian((int)value) & 0xFFFFFFFFL) << 0x20;         long i2 = FlipEndian((int)(value >> 0x20)) & 0xFFFFFFFFL;         return i1 | i2;     } }