[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference clt::cobol

Title:VAX/DEC COBOL
Notice:Kit,doc,performance talk info-->DIR/KEY=KIT or DOC or PERF_TALK
Moderator:PACKED::BRAFFITT
Created:Mon Feb 03 1986
Last Modified:Fri Jun 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:3250
Total number of notes:13077

3213.0. "Question about calculating power in DEC COBOL" by DEKVC::JOONGSUNJUN () Tue Mar 11 1997 08:00

    Hi,

    Since my customer needed to calculate power of some number, a = x ** y,
    with DEC COBOL, I have tested the calculation with compute statement,
    compute a = x ** y (I could not find any system service routines).  
    x and y might be integer or real and positive and negative.

    But, if x is negative integer or negative real and
	    y is positive real or negative real, the error occurred.

    For instance, the cases were
	compute rslt = -3 ** 1.234	or
	compute rslt = -3 ** -1.234	or
	compute rslt = -3.45 ** 1.234	or
	compute rslt = -3.45 ** -1.234.

    Please inform me any other way to calculate power of some number.

    Best Regards,
    Joong-Sun Jun.

T.RTitleUserPersonal
Name
DateLines
3213.1Are you sure that's what you want?WIBBIN::NOYCEPulling weeds, pickin' stonesTue Mar 11 1997 12:514
The problem is that raising a negative number to a non-integer power
produces a result that is a complex number, not a real number.

What is the application that makes you want to do this?