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
support your current scheme...

Bernie

--

Ontario DX Association    ===> http://www.*-*-*.com/ ~odxa
Tsuruoka Canadian Budokai ===> http://www.*-*-*.com/ ~brat/tcb
** Please remove the # from my address if replying to Usenet post!
--



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  
 
 [ 3 post ] 

 Relevant Pages 

1. Creating floating point values to & from text

2. An alternative to floating point (was Re: Floating point non-exactness)

3. IBM 370 Floating point to IEEE floating point

4. Display A Floating Point Value

5. Error in Floating Point Value - CFD 3.1

6. Error in Floating Point Value

7. Floating point value

8. ERROR In Floating Point Value

9. Urgent - Error in floating point value !

10. error in floating point value

11. Error In Floating Point Value (CDD 3.x)

12. Error in Floating point value - Clarion for Dos 3

 

 
Powered by phpBB® Forum Software