Chapter Contents

Previous

Next
HEX

HEX



Converts hexadecimal positive binary values to either integer (fixed-point) or real (floating-point) binary values

Numeric
Width range: 1- 16
Default width: 8
CMS specifics: IBM floating-point format


Syntax
Details
See Also

Syntax

HEXw.

w
specifies the field width of the input value and determines whether the input represents an integer or real binary value.


Details

Each hexadecimal digit that is read by the HEX informat is interpreted using the EBCDIC character-encoding system, with one digit per byte. For example, the hexadecimal value 'F1'x (EBCDIC 1) results in the number 1.0 using the HEX1. informat.

When you specify a width value of 1 through 15, the input hexadecimal number represents an integer binary value. When you specify 16 for the field width, the input hexadecimal number represents a real binary number.

For example, suppose a floating-point number has been stored as the following hexadecimal character value:

433E800000000000
   ('F4F3F3C5F8F0F0F0F0F0F0F0F0F0F0F0'x)

If you read the value using HEX16. as the informat, the number is converted to its correct floating-point value of 1000. However, if you specify HEX15. as the informat, SAS expects the input to represent an integer binary value. Since the number was originally stored in IBM floating-point format, the second result is incorrect.

If a number has been stored as a character representation of an integer binary value, it is correct to use a w value of less than 16. For example, if 256 has been stored as the following hexadecimal character value, then using HEX6. gives the correct result:

000100 ('F0F0F0F1F0F0'x)

However, using HEX16. produces an incorrect result of 3.38E-80 in the preceding example.

You can use the HEX informat to read negative floating-point numbers; however, it cannot be used to read negative integer binary numbers. For example, if you write -10 using the HEX16. format, it is stored in a character representation of a floating-point format, as follows:

C1A0000000000000
   ('C3F1C1F0F0F0F0F0F0F0F0F0F0F0F0F0'x)

If this character representation of a floating-point number is then read with the HEX16. informat, the value is correctly interpreted as the number -10.

However, if you write -10 as an integer binary number using the HEX2. format, it is written in EBCDIC as the hexadecimal string F6, which is the twos complement notation for -10. If you then read this value using HEX2. as the informat, it is read as a positive number, giving a result of 246.

See Also


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.