Numeric Data Input/Output [ SPL to HP C/XL Migration Guide ] MPE/iX 5.0 Documentation
SPL to HP C/XL Migration Guide
Numeric Data Input/Output
SPL programs use four MPE V intrinsics to convert ASCII data to and from
binary format. They are:
ASCII Converts 16-bit binary number to ASCII.
DASCII Converts 32-bit binary number to ASCII.
BINARY Converts ASCII byte string to 16-bit binary.
DBINARY Converts ASCII byte string to 32-bit binary.
Converting floating-point numbers requires other intrinsics.
Calls to these intrinsics have to be combined with building byte strings
"by hand", equating them to word arrays, and then passing these to MPE
V I/O intrinsics. (See the example above in "Introduction to
Input/Output").
HP C/XL standard library functions perform these operations as an
extension to the normal I/O operations.
sscanf Converts ASCII string data into all the binary formats:
signed and unsigned long and short int, char and
unsigned char, float, and double.
sprintf Converts all the binary forms above into their text
character representations, combining them with string
variables and constants.
Both of these functions allow complete format conversions. They are
considerably more powerful than the MPE intrinsic equivalents.
Four HP C/XL library functions perform both the physical I/O operation
and the format conversions at the same time. They are:
scanf Reads text from the standard input file, stdin, and
converts the ASCII text into binary numeric variables,
character variables, and strings under the control of a
format specification.
fscanf Does the same as scanf, but reads text from a specified
stream file.
printf Converts binary numeric values, character values, and
string values into ASCII text under the control of a
format specification, and writes the text to the
standard output file, stdout.
fprintf Does the same as printf, but write the text to a
specified stream file.
The simplicity and flexibility of these routines render the direct use of
the MPE intrinsics a highly questionable option. The use of standard HP
C/XL library functions in general will greatly improve portability to
another operating system such as HP-UX.
MPE/iX 5.0 Documentation