HPlogo DATA TYPES CONVERSION Programmer's Guide: HP 3000 MPE/iX Computer Systems > Chapter 3 Converting Data Types

Converting from Integer

» 

Technical documentation

Complete book in PDF
» Feedback

 » Table of Contents

 » Index

This section offers suggestions for converting integer data types to character, other integers, real and decimal data types.

To Character

Individual languages may have simple assignment functions to accept integers and store them as characters, such as the WRITE and STRWRITE command.

Signed integers in MPE XL NM are in twos complement form. MPE XL uses a 32-bit standard word in NM, and a 16-bit standard word in CM, as explained in Chapter 1, Introduction

The intrinsic DASCII accepts a 32-bit signed integer by value. It returns the value as an ASCII string to your character array and gives you the number of characters in the result string. You specify, in the parameters, whether the returned string is to be an octal (base-8), a decimal (base-10), or a hexadecimal (base-16) number. Different bases are returned with different justifications and lengths.

The intrinsic ASCII performs a similar operation with a 16-bit integer.

The compiler utility procedures INEXT ' and HPINEXT also accept an integer and return a character string of ASCII digits.

To Other Integer

All languages supported on 900 Series HP 3000 Computer Systems with the MPE XL operating system have a way, within the language, to assign value from one integer type to the other integer types.

To Real

Most high-level languages have assignments to convert integers to reals within the language.

The compiler functions DFLOAT and DFLOAT ' convert a 32-bit integer into a 64-bit real number.

To Packed Decimal

The compiler procedure HPACCVBD converts a signed binary integer to a packed decimal. The input number is considered to be in twos complement form, from 2 to 12 bytes long.

Packed-decimal procedures must be declared as intrinsics to be called from within high-level NM languages. If speed is a primary concern, consider doing packed-decimal operations within HP COBOL II/XL or HP RPG/XL.

Feedback to webmaster