Write Synch safe Int32

image_pdfimage_print
   
 

//http://walkmen.codeplex.com/license
// License:  GNU General Public License version 2 (GPLv2)  


using System;
using System.Collections.Generic;
using System.Text;

namespace Walkmen.Util
{
    public sealed class NumericUtils
    {
        private NumericUtils()
        {
        }

        public static byte[] WriteSynchsafeInt32(int value)
        {
            byte[] result = new byte[4];
            result[0] = (byte)((value & 0xFE00000) >> 21);
            result[1] = (byte)((value & 0x01FC000) >> 14);
            result[2] = (byte)((value & 0x0003F80) >> 7);
            result[3] = (byte)((value & 0x000007F));

            return result;
        }
    }
}

   
     


This entry was posted in Data Types. Bookmark the permalink.