zoukankan      html  css  js  c++  java
  • 【.NET】大小端互转,反转字节序

    代码已测试

    public static long Reverse(long value)
    {
        return (((long)Reverse((int)value) & 0xFFFFFFFF) << 32)
                | ((long)Reverse((int)(value >> 32)) & 0xFFFFFFFF);
    }
    
    public static ulong Reverse(ulong value)
    {
        return (((ulong)Reverse((uint)value) & 0xFFFFFFFF) << 32)
                | ((ulong)Reverse((uint)(value >> 32)) & 0xFFFFFFFF);
    }
    
    public static int Reverse(int value)
    {
        return (((int)Reverse((short)value) & 0xFFFF) << 16)
                | ((int)Reverse((short)(value >> 16)) & 0xFFFF);
    }
    
    public static uint Reverse(uint value)
    {
        return (((uint)Reverse((ushort)value) & 0xFFFF) << 16)
                | ((uint)Reverse((ushort)(value >> 16)) & 0xFFFF);
    }
    
    public static short Reverse(short value)
    {
        return (short)((((int)value & 0xFF) << 8) | (int)((value >> 8) & 0xFF));
    }
    
    public static ushort Reverse(ushort value)
    {
        return (ushort)((((int)value & 0xFF) << 8) | (int)((value >> 8) & 0xFF));
    }
  • 相关阅读:
    关于虚拟机链接本地磁盘文件的问题
    javaScript学习笔记
    html学习笔记
    eclipse svn插件安装
    python学习笔记一

    hive数据处理
    WordCount实验
    暑假第六周总结
    暑假第五周总结
  • 原文地址:https://www.cnblogs.com/crsky/p/14125316.html
Copyright © 2011-2022 走看看