Mono.Math.BigInteger.getBytes C# (CSharp) Method

getBytes() public method

public getBytes ( ) : byte[]
return byte[]
		public byte [] getBytes ()
		{
			if (this == 0) return new byte [1];

			int numBits = bitCount ();
			int numBytes = numBits >> 3;
			if ((numBits & 0x7) != 0)
				numBytes++;

			byte [] result = new byte [numBytes];

			int numBytesInWord = numBytes & 0x3;
			if (numBytesInWord == 0) numBytesInWord = 4;

			int pos = 0;
			for (int i = (int)length - 1; i >= 0; i--) {
				uint val = data [i];
				for (int j = numBytesInWord - 1; j >= 0; j--) {
					result [pos+j] = (byte)(val & 0xFF);
					val >>= 8;
				}
				pos += numBytesInWord;
				numBytesInWord = 4;
			}
			return result;
		}