Calculate the power of a floating point number



High Level Assembler(HLASM) for MVS & VM & VSE

Calculate the power of a floating point number

Postby Raghunaik3 » Wed Nov 21, 2018 10:33 am

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
Raghunaik3
 
Posts: 1
Joined: Wed Nov 21, 2018 10:24 am
Has thanked: 0 time
Been thanked: 0 time

Re: Calculate the power of a floating point number

Postby expat » Wed Nov 21, 2018 12:28 pm

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 ?
expat
 
Posts: 459
Joined: Sat Jun 09, 2007 3:21 pm
Has thanked: 0 time
Been thanked: 8 times

Re: Calculate the power of a floating point number

Postby enrico-sorichetti » Wed Nov 21, 2018 12:31 pm

start from

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

( You might need to register )
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2994
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 164 times

Re: Calculate the power of a floating point number

Postby steve-myers » Wed Nov 21, 2018 6:26 pm

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.
steve-myers
Global moderator
 
Posts: 2105
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 243 times

Re: Calculate the power of a floating point number

Postby enrico-sorichetti » Wed Nov 21, 2018 6:48 pm

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
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2994
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 164 times

Re: Calculate the power of a floating point number

Postby enrico-sorichetti » Wed Nov 21, 2018 6:51 pm

just found this gem

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

( one of the links returned googling as suggested )
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2994
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 164 times

Re: Calculate the power of a floating point number

Postby steve-myers » Wed Nov 21, 2018 9:12 pm

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.
steve-myers
Global moderator
 
Posts: 2105
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 243 times

Re: Calculate the power of a floating point number

Postby steve-myers » Thu Nov 22, 2018 10:30 pm

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.
steve-myers
Global moderator
 
Posts: 2105
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 243 times

Re: Calculate the power of a floating point number

Postby Terry Heinze » Fri Nov 23, 2018 8:06 pm

The Windows 7 calculator gives Y ^ Z = 8298.38 (rounded to 2 decimals)
.... Terry
Terry Heinze
 
Posts: 239
Joined: Wed Dec 04, 2013 11:08 pm
Location: Richfield, MN, USA
Has thanked: 12 times
Been thanked: 11 times

Re: Calculate the power of a floating point number

Postby steve-myers » Fri Nov 23, 2018 8:30 pm

I got essentially the same result from Calc in LibreOffice.
steve-myers
Global moderator
 
Posts: 2105
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 243 times

Next

Return to Assembler

 


  • Related topics
    Replies
    Views
    Last post