Page 1 of 2

Calculate the power of a floating point number

PostPosted: Wed Nov 21, 2018 10:33 am
by Raghunaik3
Hi Can we implement the equation like A = X * ((1 + Y)**Z) in mainframe assembler
Where both Y and Z can be a floating point number like 2.35 or 3.256

If yes can you please let me how to do it


Thanks

Re: Calculate the power of a floating point number

PostPosted: Wed Nov 21, 2018 12:28 pm
by expat
What have you tried so far, and what results did you get ?
What research have you done - as your question asks if it is possible or not - surely you have googled at least ?

Re: Calculate the power of a floating point number

PostPosted: Wed Nov 21, 2018 12:31 pm
by enrico-sorichetti
start from

http://www-01.ibm.com/support/docview.w ... c500428f9a

( You might need to register )

Re: Calculate the power of a floating point number

PostPosted: Wed Nov 21, 2018 6:26 pm
by steve-myers
I'm not so confident Mr. Sorichetti's link will be of direct assistance. The key is Y**Z where Y and Z are floating point. I don't think there is a single instruction to do Y**Z. If I ever knew how to do Y**Z, it has certainly flown away from my memory. Other than Y**Z the remainder is parsing out the operands and doing the arithmetic.

It's not so hard for an unregistered person to download the z/Architecture Principles of Operation. I just did that 11 days ago! It just takes some patience and Google.

Re: Calculate the power of a floating point number

PostPosted: Wed Nov 21, 2018 6:48 pm
by enrico-sorichetti
I knew that ... :ugeek:
but even doing simple arithmetics using floating point is not that easy
and the TS will NEED to look at the principles of operations anyway

the TS might want to do a bit of homework by looking at the links provided by a simple google search
using ibm assembler floating point examples

Re: Calculate the power of a floating point number

PostPosted: Wed Nov 21, 2018 6:51 pm
by enrico-sorichetti
just found this gem

http://idcp.marist.edu/enterprisesystem ... ervers.pdf

( one of the links returned googling as suggested )

Re: Calculate the power of a floating point number

PostPosted: Wed Nov 21, 2018 9:12 pm
by steve-myers
I've had that book for some time (April 2017). I found it, originally, through http://www.cbttape.org. Awfully long winded, though. As a text book, I'd estimate it has enough material for at least 4 semesters

Actually, when I said I got the z/Arch POP 11 days ago, it turned out I was mistaken. That was the last time I looked at it. The file was allocated August 23.

Re: Calculate the power of a floating point number

PostPosted: Thu Nov 22, 2018 10:30 pm
by steve-myers
Raghunaik3 wrote:Hi Can we implement the equation like A = X * ((1 + Y)**Z) in mainframe assembler
Where both Y and Z can be a floating point number like 2.35 or 3.256

If yes can you please let me how to do it


Thanks

Going back to the original question, I wrote up a little Fortran program -
      Y=57.2
      Z=2.23
      RES = Y ** Z
      WRITE (6,2001) Y,Z,RES
 2001 FORMAT(' ', F7.2, ' ** ',F7.2,' = ',F7.2)
      STOP
      END

I ran the program through the OS/360 Fortran G compiler in the hope its Assembler listing might provide some insight. It didn't. If I read it right, the code called a library routine to perform Y ** Z.

The output of the WRITE statement was
 57.20 **    2.23 = 8298.35

This seems to be right.

Re: Calculate the power of a floating point number

PostPosted: Fri Nov 23, 2018 8:06 pm
by Terry Heinze
The Windows 7 calculator gives Y ^ Z = 8298.38 (rounded to 2 decimals)

Re: Calculate the power of a floating point number

PostPosted: Fri Nov 23, 2018 8:30 pm
by steve-myers
I got essentially the same result from Calc in LibreOffice.