Creating floating point values to & from text
Author Message
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.

One approach you could take, other than the painful one of getting out the
Principles of Operations manual and boning up on floating point
representation:--

Use the information collected by your current %include parser to generate a
PL/I program to do the editting and conversion. Then you could use all of
PL/I's facilities, which already do the hard stuff for you.
Mind it might require some more machinery than you have in place to

Bernie

--

Ontario DX Association    ===> http://www.*-*-*.com/ ~odxa
Tsuruoka Canadian Budokai ===> http://www.*-*-*.com/ ~brat/tcb
--

Sun, 23 Apr 2000 03:00:00 GMT
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...

Sun, 23 Apr 2000 03:00:00 GMT

 Page 1 of 1 [ 3 post ]

Relevant Pages