Browse Prior Art Database

Nonlooping Mechanism for Character Conversion

IP.com Disclosure Number: IPCOM000078955D
Original Publication Date: 1973-Apr-01
Included in the Prior Art Database: 2005-Feb-26
Document File: 3 page(s) / 15K

Publishing Venue

IBM

Related People

Etchison, KL: AUTHOR

Abstract

It often becomes necessary in APL programming to output a matrix, vector, or number to a terminal in a particular format, with a predetermined number of digits printed, decimal point and sign in place and leading zeroes removed.

This text was extracted from a PDF file.
This is the abbreviated version, containing approximately 56% of the total text.

Page 1 of 3

Nonlooping Mechanism for Character Conversion

It often becomes necessary in APL programming to output a matrix, vector, or number to a terminal in a particular format, with a predetermined number of digits printed, decimal point and sign in place and leading zeroes removed.

The existing APL function available for this purpose, DFT involves APL instruction loops. Here described is a program that provides the same capability as DFT with no loops. In addition, there is no restriction as to the rank of the matrix to be formatted.

Two concepts are basic to this program. The first is the conversion of the matrix to a base 14 number system to allow representation of blanks, decimal point, and sign in addition to digits within a single number. The second involves removal of leading zeroes and insertion of the sign in a single operation, involving the computation of residuals of divisions by numbers containing information about the sign as the value in a position, and the number of significant positions as the position of the value. Procedure.

Matrix "M" is input to the program with a request for "C" characters and "D" digits following the decimal point. Following is a step-by-step description of the process, including the APL statements performing the described functions.
1. Create a new matrix, "S", indicating the sign of the

numbers in the input matrix as follows:

negative = 2

nonnegative = 1

S <-- 1+ 1=xM.
2. Take the absolute value of all numbers in the input

matrix

and round to the nearest (.1)/n/, where n is the number of

digits to be displayed following the decimal point.

M <-- (.1*D)xL.5+Mx10*D.
3. If any digits were requested following the decimal point,

multiply the integer portion of all numbers by 10.

M <-- M+(xD)x 9xM.
4. Multiply all numbers by 10/n/ where n is the number of

digits to be displayed following the decimal point.

M <-- Mx10*D.
5. Compute the dimensions of the output matrix equal to the

dimensions of the input matrix, with the last dimension

multiplied by the number of characters to be displayed

per number.

DIM <-- rho M

DIML rho DIM <-- DIM rho DIM x C.
6. At this point, the input matrix has been converted to a

matrix of positive integers. The low-order n digits,

base 10, are the n digits to be printed after the decimal

point. The n+1/st/ digit is zero.

Example: 7 digits to be printed, 2 after the

decimal point, input matrix =

1

Page 2 of 3

76.263 -3.351 -6.357

1.6 127 16.7

7.16 1.166 .02

"M" = 76026 3035 6036

1060 127000 16070

7016 1017 2

"S" = 1 2 2

1 1 1

1 1 1

DIM = (3 21)
7. Create a new matrix whose elements represent the number

of significant positions (SP) for each element of "M" as the

maximum of the number of significant positions in the

element, or the number of digits following the decimal

point plus two (or one if no digits are to follow the

decimal point).

SP <-- (1+D+xD) (1x10*M+M=0)

SP = 5 4 4

4 6 5

4 4 4
8. Using this matrix and the sign matrix created in step 1,

create a new matrix by raising 14...