Chapter Contents

Previous

Next
SAS/C Compiler Changes in Release 7.50

Floating-Point Changes for SAS/C Release 7.50

The SAS/C compiler and library's floating-point support has been extensively changed and improved for Release 7.50. The changes are concentrated in three distinct, but overlapping areas:


IEEE Floating-Point Support

The ISO standards document IEC 60559 defines a portable standard for floating-point computation known informally as IEEE floating-point. This standard is implemented by almost all computer systems presently in use. Until recently, the major exception to this statement was the IBM mainframe, which offered a different floating-point implementation defined by IBM in the 1960's. In the last decade, IBM has remedied this situation by offering an implementation of IEEE floating-point parallel to traditional IBM floating-point. Depending on their requirements, mainframe programs can choose to use traditional IBM floating-point, the more portable IEEE floating-point, or, for very advanced applications, both floating-point implementations.

There are advantages and limitations to the use of IEEE floating-point by applications, and the choice between traditional mainframe floating-point and IEEE floating-point is not always obvious.

Advantages of IEEE Floating-Point

The following list contains a few of the reasons that you might prefer to use IEEE floating-point:


Advantages of the Traditional Mainframe Floating-Point

The following list contains a few of the reasons that you might prefer to use traditional mainframe floating-point:

IBM's traditional floating-point format uses a base-16 representation, that is, the exponent represents a power of sixteen. IEEE floating-point uses a binary representation, with the exponent representing a power of two. For this reason, IBM calls its traditional floating-point format HFP (hexadecimal floating-point), and its IEEE format BFP (binary floating point). HFP and BFP are used as synonyms for traditional mainframe floating-point and IEEE floating-point in the rest of this document.


SAS/C IEEE Support

When you compile a SAS/C program, you can specify the BFP or NOBFP option to specify whether the default floating-point format is BFP or HFP. HFP is the default.

SAS/C enables programs to use both floating-point formats. This is a useful option for programs such as debuggers, and for subroutine libraries whose users want a choice of format. To support the use of both formats, SAS/C provides the _ _binfmt and _ _hexfmt type modifiers, which can be used to specify the floating-point format independently of whether the BFP option is used. Similarly, H and B suffixes can be used with floating-point constants to indicate the format.

Using Both IBM and IEEE Floating-Point Formats contains detailed rules on mixing the two formats, but the basic premise you should keep in mind is: You can use casts to convert between the two formats, but mixed-mode expressions are, in general, not supported. In other words, if you try to add a _ _binfmt double to a _ _hexfmt double, the compiler cannot determine which kind of addition operation it should perform. You therefore have to code a cast of one operand to the format of the other.

The SAS/C library of mathematical functions is completely supported for both traditional and IEEE floating-point. However, some functions (such as isinf, which tests to see if its argument is an infinite number) are not meaningful for hexadecimal floating point, and return dummy results of little utility.

SAS/C has added format modifiers to the printf and scanf series of functions to enable either format of floating-point number to be read or written. If a format specifier does not have a floating-point type, the corresponding argument is assumed to have the default floating-point format. Use of the extensions is not required for programs which use only one kind of floating-point.


SAS/C and Mainframe Floating-Point Extensions

The most recent generations of IBM mainframes have included extensions to the floating-point hardware which enable improved performance for traditional floating-point as well as for IEEE support. The SAS/C compiler option ARCHLEVEL(C) can be specified to cause the compiler to generate code that targets the newer floating-point hardware. If you specify the BFP option, ARCHLEVEL(C) is the default ARCHLEVEL setting.

The two main advantages of ARCHLEVEL(C) for traditional floating-point code are:


SAS/C C99 Support

SAS/C Release 7.50 supports many elements of the ISO C99 standard relating to floating-point. Some of these elements are oriented specifically to IEEE floating-point, but most apply to both formats.

The most significant SAS/C enhancements in support of C99 are:


Chapter Contents

Previous

Next

Top of Page

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