Fan.Sys.FanInt.random C# (CSharp) Method

random() public static method

public static random ( ) : long
return long
        public static long random()
        {
            return random(null);
        }

Same methods

FanInt::random ( Range r ) : long

Usage Example

Example #1
0
            private long toLong(byte[] bytes)
            {
                // if bytes less then 6 pad with random
                if (bytes.Length < 6)
                {
                    byte[] temp = new byte[6];
                    Array.Copy(bytes, 0, temp, 0, bytes.Length);
                    for (int i = bytes.Length; i < temp.Length; ++i)
                    {
                        temp[i] = (byte)FanInt.random();
                    }
                    bytes = temp;
                }

                // mask bytes into 6 byte long
                long x = ((bytes[0] & 0xFFL) << 40) |
                         ((bytes[1] & 0xFFL) << 32) |
                         ((bytes[2] & 0xFFL) << 24) |
                         ((bytes[3] & 0xFFL) << 16) |
                         ((bytes[4] & 0xFFL) << 8) |
                         ((bytes[5] & 0xFFL) << 0);

                // if we have more then six bytes mask against primary six bytes
                for (int i = 6; i < bytes.Length; ++i)
                {
                    x ^= (bytes[i] & 0xFFL) << (((i - 6) % 6) * 8);
                }

                return(x);
            }
All Usage Examples Of Fan.Sys.FanInt::random