public override byte[] EncodeValue(ScalarValue v)
        {
            if (v == ScalarValue.NULL)
            {
                return(NULL_VALUE_ENCODING);
            }

            var buffer        = new System.IO.MemoryStream();
            var value_Renamed = (DecimalValue)v;

            try
            {
                if (Math.Abs(value_Renamed.exponent) > 63)
                {
                    Global.HandleError(Error.FastConstants.R1_LARGE_DECIMAL, "");
                }

                byte[] temp_byteArray = NULLABLE_INTEGER.Encode(new IntegerValue(value_Renamed.exponent));
                buffer.Write(temp_byteArray, 0, temp_byteArray.Length);
                byte[] temp_byteArray2 = INTEGER.Encode(new LongValue(value_Renamed.mantissa));
                buffer.Write(temp_byteArray2, 0, temp_byteArray2.Length);
            }
            catch (System.IO.IOException e)
            {
                throw new RuntimeException(e);
            }

            return(buffer.ToArray());
        }
Exemple #2
0
        public override ScalarValue Decode(System.IO.Stream in_Renamed)
        {
            ScalarValue subtractionLength = NULLABLE_INTEGER.Decode(in_Renamed);

            if (subtractionLength == null)
            {
                return(null);
            }

            ScalarValue difference = ASCII.Decode(in_Renamed);

            return(new TwinValue(subtractionLength, difference));
        }
        public override ScalarValue Decode(System.IO.Stream in_Renamed)
        {
            ScalarValue exp = NULLABLE_INTEGER.Decode(in_Renamed);

            if ((exp == null) || exp.Null)
            {
                return(null);
            }

            int  exponent     = exp.ToInt();
            long mantissa     = INTEGER.Decode(in_Renamed).ToLong();
            var  decimalValue = new DecimalValue(mantissa, exponent);

            return(decimalValue);
        }
Exemple #4
0
        public override byte[] EncodeValue(ScalarValue value_Renamed)
        {
            if (value_Renamed.Null)
            {
                return(NULL_VALUE_ENCODING);
            }

            var diff = (TwinValue)value_Renamed;

            byte[] subtractionLength = NULLABLE_INTEGER.Encode(diff.first);
            byte[] difference        = ASCII.Encode(diff.second);
            var    encoded           = new byte[subtractionLength.Length + difference.Length];

            Array.Copy(subtractionLength, 0, encoded, 0, subtractionLength.Length);
            Array.Copy(difference, 0, encoded, subtractionLength.Length, difference.Length);

            return(encoded);
        }