コード例 #1
0
        /// <summary>
        /// Gets a {@code short} at memory address {@code p} by reading byte for byte, instead of the whole value
        /// in one go. This can be useful, even necessary in some scenarios where <seealso cref="allowUnalignedMemoryAccess"/>
        /// is {@code false} and {@code p} isn't aligned properly. Values read with this method should have been
        /// previously put using <seealso cref="putShortByteWiseLittleEndian(long, short)"/>.
        /// </summary>
        /// <param name="p"> address pointer to start reading at. </param>
        /// <returns> the read value, which was read byte for byte. </returns>
        public static short GetShortByteWiseLittleEndian(long p)
        {
            short a = ( short )(UnsafeUtil.GetByte(p) & 0xFF);
            short b = ( short )(UnsafeUtil.GetByte(p + 1) & 0xFF);

            return(( short )((b << 8) | a));
        }
コード例 #2
0
        /// <summary>
        /// Gets a {@code int} at memory address {@code p} by reading byte for byte, instead of the whole value
        /// in one go. This can be useful, even necessary in some scenarios where <seealso cref="allowUnalignedMemoryAccess"/>
        /// is {@code false} and {@code p} isn't aligned properly. Values read with this method should have been
        /// previously put using <seealso cref="putIntByteWiseLittleEndian(long, int)"/>.
        /// </summary>
        /// <param name="p"> address pointer to start reading at. </param>
        /// <returns> the read value, which was read byte for byte. </returns>
        public static int GetIntByteWiseLittleEndian(long p)
        {
            int a = UnsafeUtil.GetByte(p) & 0xFF;
            int b = UnsafeUtil.GetByte(p + 1) & 0xFF;
            int c = UnsafeUtil.GetByte(p + 2) & 0xFF;
            int d = UnsafeUtil.GetByte(p + 3) & 0xFF;

            return((d << 24) | (c << 16) | (b << 8) | a);
        }
コード例 #3
0
        /// <summary>
        /// Gets a {@code long} at memory address {@code p} by reading byte for byte, instead of the whole value
        /// in one go. This can be useful, even necessary in some scenarios where <seealso cref="allowUnalignedMemoryAccess"/>
        /// is {@code false} and {@code p} isn't aligned properly. Values read with this method should have been
        /// previously put using <seealso cref="putLongByteWiseLittleEndian(long, long)"/>.
        /// </summary>
        /// <param name="p"> address pointer to start reading at. </param>
        /// <returns> the read value, which was read byte for byte. </returns>
        public static long GetLongByteWiseLittleEndian(long p)
        {
            long a = UnsafeUtil.GetByte(p) & 0xFF;
            long b = UnsafeUtil.GetByte(p + 1) & 0xFF;
            long c = UnsafeUtil.GetByte(p + 2) & 0xFF;
            long d = UnsafeUtil.GetByte(p + 3) & 0xFF;
            long e = UnsafeUtil.GetByte(p + 4) & 0xFF;
            long f = UnsafeUtil.GetByte(p + 5) & 0xFF;
            long g = UnsafeUtil.GetByte(p + 6) & 0xFF;
            long h = UnsafeUtil.GetByte(p + 7) & 0xFF;

            return((h << 56) | (g << 48) | (f << 40) | (e << 32) | (d << 24) | (c << 16) | (b << 8) | a);
        }