Creating floating point values to & from text

Quote:

> >Hi,

> >I've written an exec that allows users to browse or edit files using PL/I

> >%include books to map the source into something they can read.

> >[...]

> >Now someone has asked me to add some when's to cater for floating point

> >numbers and I'm pretty miffed, as I haven't got a clue how they (short,

> >long and extended) are represented internally.

Bit 0 is the sign, 0=positive, 1=negative

Bits 1-7 are the exponent in what is known as "excess-64 notation." That is,

a value of X'40' indicates an exponent of zero, as in "16**0," a value of X'41'

means 16**1, and X'3F' is 16**-1.

The rest of the number, bits 8-31/63 is the fraction.

Conversion of the number is simple:

1) Scale the fraction UP or DOWN by the number of decimal places you wish

to print.

2) Perform successive divisions by 10 (or whatever radix you are converting to)

and extract only the remainder.

3) Note that editting proceeds from right to left.

good luck...