MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Negative base with fractional Exponents

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
seekaysk
Beginner


Joined: 31 Aug 2007
Posts: 49
Topics: 15

PostPosted: Thu Oct 23, 2008 8:10 am    Post subject: Negative base with fractional Exponents Reply with quote

Hi guys,

I tried to find this on NET as well as MVSFORUMS search but could not get anything substantial.

I want to find

a) how does Cobol calculate a Negative base with fractional components ? or does it even calculate it or not ?

e.g. (-5)**(0.2593)

b) If expecting above answer is illogical (as what is suggested in the below MVS message), what should we do in practical terms ? Can anybody suggest me that not coding ON SIZE ERROR and putting negative sign in the result, is it logical ?

e.g. if Z = (5)**(0.2593), then actual result = -Z. is this logical ?

fyi. I found this one message on MVS which gives at run time:

******************************************************
IGZ0048W
IGZ0048W A negative base was raised to a fractional power in an exponentiation expression in program program-name at displacement displacement. The absolute value of the base was used.

Explanation: A negative number raised to a fractional power occurred in a library routine.

The value of a negative number raised to a fractional power is undefined in COBOL. If a SIZE ERROR clause had appeared on the statement in question, the SIZE ERROR imperative would have been used. However, no SIZE ERROR clause was present, so the absolute value of the base was used in the exponentiation.

Programmer Response: Ensure that the program variables in the failing statement have been set correctly.

System Action: No system action was taken.
******************************************************
_________________
Thanks.
Back to top
View user's profile Send private message
dbzTHEdinosauer
Supermod


Joined: 20 Oct 2006
Posts: 1411
Topics: 26
Location: germany

PostPosted: Thu Oct 23, 2008 8:18 am    Post subject: Reply with quote

I would think this is something fortran would handle better than COBOL, and that is were you should go. FORTRAN is provided by IBM as a programming language.

FORTRAN - formula translation

COBOL - common business oriented language.
_________________
Dick Brenholtz
American living in Varel, Germany
Back to top
View user's profile Send private message
jsharon1248
Intermediate


Joined: 08 Aug 2007
Posts: 291
Topics: 2
Location: Chicago

PostPosted: Thu Oct 23, 2008 10:41 am    Post subject: Reply with quote

I'd do some research. I don't know that what you're trying to do is valid. I tried (-5**.2593) in a calculator and in Excel, and both returned errors indicating that this is not valid. I'm not a mathemetician, so I can't be sure, but it seems to me that what you're trying to do doesn't make sense. COBOL is just telling you that it's doing the best it can with what you provided, so if that's not good enough, you'll need to decide how you want to handle it. Probably checking for the negative base and issuing your own warning is the best option.
Back to top
View user's profile Send private message
sriramla
Beginner


Joined: 22 Feb 2003
Posts: 74
Topics: 1

PostPosted: Thu Oct 23, 2008 10:51 am    Post subject: Reply with quote

As you know, (-5)**1 gives you a negative number as the result. But (-5)**2 gives you a positive number. In general, negative number raised to the power of odd number will give a negative number as the result; raised to even number will give a positive number as the result.

Having said that (-5)**0.5 (In other words, square root of -5) is a complex number and it makes very little sense in business applications. That is why you get this warning message. Regarding your question "if Z = (5)**(0.2593), then actual result = -Z. is this logical?" this is not correct.

May be you want to check how the result of this computation is being used and make a decision.
Back to top
View user's profile Send private message
seekaysk
Beginner


Joined: 31 Aug 2007
Posts: 49
Topics: 15

PostPosted: Thu Oct 23, 2008 11:17 am    Post subject: Reply with quote

Thanks for the replies. I am at a financial shop. The equation I gave is used for Annualized formula calculation. Hence, having -5 as a Return is absolutely valid in a financial shop.
_________________
Thanks.
Back to top
View user's profile Send private message
jsharon1248
Intermediate


Joined: 08 Aug 2007
Posts: 291
Topics: 2
Location: Chicago

PostPosted: Thu Oct 23, 2008 1:09 pm    Post subject: Reply with quote

If it's true that when the base is negative, the result will be a negative return, then you should use the absolute value of the base, raise it to the appropriate exponent, and then multiply the result by -1.

Code:
IF BASE-AMT < +0
    COMPUTE RETURN-AMT = ((BASE-AMT * -1) ** EXP-VAL) * -1
ELSE
    COMPUTE RETURN-AMT = BASE-AMT ** EXP-VAL
END-IF
Back to top
View user's profile Send private message
seekaysk
Beginner


Joined: 31 Aug 2007
Posts: 49
Topics: 15

PostPosted: Thu Oct 23, 2008 3:05 pm    Post subject: Reply with quote

thanks jsharon1248 and all. I am still not sure whether multiplying the result by -1 is the exact logical thing to do...and that's the reason i had this thread so that I can know the experts views. I am still looking forward to if somebody has something else what the above guys could not post. Else I will close this thread concluding it's application specific to get the workaround of multiplying the result by -1 or just send warning to user.

thanks to all. As always, its a pleasure to know the views of the best in the industry.
_________________
Thanks.
Back to top
View user's profile Send private message
Dibakar
Advanced


Joined: 02 Dec 2002
Posts: 700
Topics: 63
Location: USA

PostPosted: Mon Oct 27, 2008 8:30 pm    Post subject: Reply with quote

seekaysk,

I will go with what srirmala said. So there is no point in going for negative base unless you want to deal with imaginary amounts. This is what google calculator shows - http://www.google.com/search?sourceid=navclient&ie=UTF-8&rlz=1T4GPCK_enUS291US292&q=%28%2d5%29+%2a%2a%280%2e2593%29%3d

But still I will go with jsharon's logic. To me there is no negative amount, it is either credit or debit. So I will take the exponent of positive base and put the sign in front to show who owes the money. I hope this makes sense in your case too.

Diba.
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group