Previous Page | Next Page

Informats under OpenVMS

RBw.d Informat: OpenVMS

Reads real (floating-point) binary values.
Category: numeric
Width range: 2 to 8
Default width: 4
Decimal range: 0 to 10
OpenVMS specifics: native floating-point representation
See: RBw.d Informat in SAS Language Reference: Dictionary

Example 1: Single- versus Double-Precision Representation
Example 2: Writing External Data
See Also




specifies the width of the input field.


specifies the power of 10 by which to divide the input value. This argument is optional. If you specify d, the RBw.d informat divides the input value by the 10d value. SAS uses the d value even if the input data contains decimal points.


The RBw.d informat reads numeric data that is stored in native real-binary (floating-point) notation. Numeric data for scientific calculations is often stored in floating-point notation. (SAS stores all numeric values in floating-point notation.) A floating-point value consists of two parts: a mantissa that gives the value and an exponent that gives the value's magnitude.

It is usually impossible to key in floating-point binary data directly from a terminal, but many programs write floating-point binary data. Use caution if you are using the RBw.d informat to read floating-point data created by programs other than SAS because the RBw.d informat is designed to read-only double-precision data.

Because the RBw.d informat is designed to read-only double-precision data, it supports widths of less than 8 bytes only for those applications that truncate numeric data for space-saving purposes. RB4., for example, does not expect a single-precision number that is truncated to 4 bytes.

External programs such as those written in C and FORTRAN can produce only single- or double-precision floating-point numbers. No length other than 4 or 8 bytes is allowed. The RBw.d informat allows a length of 3 through 8 bytes, depending on the storage you need to save.

The FLOAT4. informat has been created to read a single-precision, floating-point number. If you read the hexadecimal notation 3F800000 with FLOAT4., the result is a value of 1.

To read data created by a C or FORTRAN program, you need to decide on the proper informat to use. If the floating-point numbers require an 8-byte width, you should use the RB8. informat. If the floating-point numbers require a 4-byte width, you should use FLOAT4.

For more information about OpenVMS floating-point representation, see HP OpenVMS Programming Concepts Manual, Volume II, Part I, OpenVMS Programming Interfaces: Calling a System Routine.


Example 1: Single- versus Double-Precision Representation

Consider how the value of 1 is represented in single-precision and double-precision notation. For single-precision, the hexadecimal representation of the 4 bytes of data is 3F800000 . For double-precision, the hexadecimal representation is 3FF0000000000000 . The digits at the beginning of the data are different, indicating a different method of storing the data.

Example 2: Writing External Data

Consider this C example:

#include <stdio.h>

main() {

FILE *fp;
float x[3];

fp = fopen("test.dat","wb");
x[0] = 1; x[1] = 2; x[2] = 3;

fwrite((char *)x,sizeof(float),3,fp);

The file TEST.DAT will contain, in hexadecimal notation, 3f8000004000000040400000 .

See Also

Previous Page | Next Page | Top of Page