public object ConvertFrom(byte[] decimalBuf) { var bigintBytes = new byte[decimalBuf.Length - 4]; Array.Copy(decimalBuf, 4, bigintBytes, 0, bigintBytes.Length); var scale = (byte)TypeCodec.BytesToInt32(decimalBuf, 0); Array.Reverse(bigintBytes); var bigInteger = new BigInteger(bigintBytes); var isNegative = bigInteger < 0; bigInteger = BigInteger.Abs(bigInteger); bigintBytes = bigInteger.ToByteArray(); if (bigintBytes.Length > 13 || (bigintBytes.Length == 13 && bigintBytes[12] != 0)) { throw new ArgumentOutOfRangeException( "decimalBuf", "this java.math.BigDecimal is too big to fit into System.Decimal. Think about using other TypeAdapter for java.math.BigDecimal (e.g. J#, IKVM,...)"); } var intArray = new int[3]; Buffer.BlockCopy(bigintBytes, 0, intArray, 0, Math.Min(12, bigintBytes.Length)); return(new decimal(intArray[0], intArray[1], intArray[2], isNegative, scale)); }