src/NeinMath/IntegerConverter.cs
/// <summary>
/// Returns an Integer converted from an array of bytes.
/// </summary>
/// <param name="value">An array of bytes.</param>
/// <returns>An Integer formed by an array of bytes.</returns>
Returns an Integer converted from an array of bytes.
Returns an Integer converted from an array of bytes .
public static Integer FromByteArray(byte[] value)
        {
            if (value == null)
                throw new ArgumentNullException(nameof(value));
            var sign = value.Length != 0
                && (value[value.Length - 1] & 0x80) != 0;
            if (sign)
                value = Bits.TwosComplement(value, value.Length);
            var bits = new uint[(value.Length + 3) / 4];
            for (var i = 0; i < value.Length; i++)
            {
                var shift = (i % 4) * 8;
                bits[i / 4] |= (uint)(value[i] << shift);
            }
            return new Integer(bits, bits.Length, sign);
        }
public static Integer FromByteArray ( byte [ ] value ) { if ( value == null ) throw new ArgumentNullException ( nameof ( value ) ) ; var sign = value . Length != 0 && ( value [ value . Length - 1 ] & 0x80 ) != 0 ; if ( sign ) value = Bits . TwosComplement ( value , value . Length ) ; var bits = new uint [ ( value . Length + 3 ) / 4 ] ; for ( var i = 0 ; i < value . Length ; i ++ ) { var shift = ( i % 4 ) * 8 ; bits [ i / 4 ] |= ( uint ) ( value [ i ] << shift ) ; } return new Integer ( bits , bits . Length , sign ) ; }
Returns an Integer converted from an array of bytes.
Returns an Integer converted from an array of bytes .
An Integer formed by an array of bytes.
An Integer formed by an array of bytes .
value
byte[]
An array of bytes.
An array of bytes .