Numeric encoding
If you set the MQMessage Encoding property, the following methods convert between different numeric encoding systems:
- ReadDecimal2 method
- ReadDecimal4 method
- ReadDouble method
- ReadDouble4 method
- ReadFloat method
- ReadInt2 method
- ReadInt4 method
- ReadLong method
- ReadShort method
- ReadUInt2 method
- WriteDecimal2 method
- WriteDecimal4 method
- WriteDouble method
- WriteDouble4 method
- WriteFloat method
- WriteInt2 method
- WriteInt4 method
- WriteLong method
- WriteShort method
- WriteUInt2 method
The Encoding property can be set and interpreted using the supplied WebSphere MQ constants.
Figure 1 shows an example of these:
Figure 1. Supplied WebSphere MQ constants for encoding/* Encodings for Binary Integers */ MQENC_INTEGER_UNDEFINED MQENC_INTEGER_NORMAL MQENC_INTEGER_REVERSED /* Encodings for Decimals */ MQENC_DECIMAL_UNDEFINED MQENC_DECIMAL_NORMAL MQENC_DECIMAL_REVERSED /* Encodings for Floating-Point Numbers */ MQENC_FLOAT_UNDEFINED MQENC_FLOAT_IEEE_NORMAL MQENC_FLOAT_IEEE_REVERSED MQENC_FLOAT_S390For example, to send an integer from an Intel system to a System/390 operating system in System/390 encoding:
Dim msg As New MQMessage 'Define an WebSphere MQ message for our use.. Print msg.Encoding 'Currently 546 (or X'222') 'Set the encoding property to 785 (or X'311') msg.Encoding = MQENC_INTEGER_NORMAL OR MQENC_DECIMAL_NORMAL OR MQENC_FLOAT_S390 Print msg.Encoding 'Print it to see the change Dim local_num As long 'Define a long integer local_num = 1234 'Set it msg.WriteLong(local_num) 'Write the number into the message