Exemple #1
0
        /// <summary>
        /// Reads a single precision 32-bit floating point number from the stream
        /// that has been encoded in IBM System/360 Floating Point format
        /// </summary>
        /// <returns>IEEE formatted single precision floating point</returns>
        public static float ReadSingleIbm(this BinaryReader reader)
        {
            if (ReferenceEquals(null, reader))
            {
                throw new ArgumentNullException("reader");
            }
            var bytes = ReadBytes(reader, 4);

            return(IbmConverter.ToSingle(bytes));
        }
Exemple #2
0
        /// <summary>
        /// Reads a pack decimal from the stream
        /// </summary>
        /// <param name="reader">The reader from which the bytes will be read</param>
        /// <param name="storageLength">The total storage length of the packed decimal</param>
        /// <param name="scale">The scale of the decimal (number of number after the .)</param>
        /// <returns>The decimal read from the stream</returns>
        public static decimal ReadPackedDecimalIbm(this BinaryReader reader, byte storageLength, byte scale)
        {
            if (ReferenceEquals(null, reader))
            {
                throw new ArgumentNullException("reader");
            }
            var bytes = ReadBytes(reader, storageLength);

            return(IbmConverter.ToUnpackedDecimal(bytes, scale));
        }
Exemple #3
0
        /// <summary>
        /// Reads the requested number of 8-bit EBCDIC encoded characters from the stream and converts them to a
        /// Unicode string.
        /// </summary>
        /// <param name="count">The number of bytes to read</param>
        /// <returns>
        /// Unicode encoded string converted from bytes read from the stream.
        /// The length of the string might be less than the number of bytes requested if the end of the stream is reached.
        /// </returns>
        public static string ReadStringEbcdic(this BinaryReader reader, int count)
        {
            if (ReferenceEquals(null, reader))
            {
                throw new ArgumentNullException("reader");
            }
            var bytes = reader.ReadBytes(count);

            return(IbmConverter.ToString(bytes));
        }
Exemple #4
0
        /// <summary>
        /// Reads a 32-bit integer from the stream that has been encoded as big endian.
        /// </summary>
        public static Int32 ReadInt32BigEndian(this BinaryReader reader)
        {
            if (ReferenceEquals(null, reader))
            {
                throw new ArgumentNullException("reader");
            }
            var bytes = ReadBytes(reader, 4);

            return(IbmConverter.ToInt32(bytes));
        }
Exemple #5
0
        /// <summary>
        /// Writes a packed decimal to the stream
        /// </summary>
        public static void WriteIbmPackedDecimal(this BinaryWriter writer, decimal value)
        {
            var bytes = IbmConverter.GetBytes(value);

            writer.Write(bytes);
        }
Exemple #6
0
        /// <summary>
        /// Writes an IBM System/360 Floating Point encoded Single to the stream
        /// </summary>
        public static void WriteIbmSingle(this BinaryWriter writer, Single value)
        {
            var bytes = IbmConverter.GetBytes(value);

            writer.Write(bytes);
        }
Exemple #7
0
        /// <summary>
        /// Writes a big endian encoded Int32 to the stream
        /// </summary>
        public static void WriteBigEndian(this BinaryWriter writer, Int32 value)
        {
            var bytes = IbmConverter.GetBytes(value);

            writer.Write(bytes);
        }
Exemple #8
0
        /// <summary>
        /// Writes the given Unicode string as an 8-bit EBCDIC encoded character string
        /// </summary>
        public static void WriteEbcdic(this BinaryWriter writer, string value)
        {
            var bytes = IbmConverter.GetBytes(value);

            writer.Write(bytes);
        }
        /// <summary>
        /// Writes a big endian encoded Int32 to the stream
        /// </summary>
        public static void WriteBigEndian32FromSingle(this BinaryWriter writer, float value)
        {
            var bytes = IbmConverter.GetBytes((int)value);

            writer.Write(bytes);
        }