3

I have a little problem I don't know tow to turn in deegrees my ATAN/ASIN/ACOS function in cobol This is the code:

                     ACCEPT A
                       COMPUTE C= FUNCTION ATAN(A)
                           END-COMPUTE
                          DISPLAY "Computing."
               DISPLAY "Computing.."
               DISPLAY "Computing..."
               DISPLAY "Computing...."
               DISPLAY "Computing....."
               DISPLAY "Computing......"
               DISPLAY "LA TANGENTE^-1 DI " A " RISULTA..."
                           DISPLAY C " GRADI"

Have you ideas? The (A * 180 /3.14) idea that I had doesen't work, for example, my scientific calc says that tan^-1 of 15 is 86.1, and the COBOL program says, with only A, 0000001.5042281, and with (A * 180 /3.14) says 0000001.5696333 Have you ideas?

aIDserse
  • 131
  • 8
  • 1
    `DISPLAY` doesn't accept expressions, so you'll need to explicitly compute a result in degrees. *FUNCTION ATAN is in radians, as mentioned elsewhere. `COMPUTE D = FUNCTION ATAN(A) * 180 / FUNCTION PI` and `DISPLAY D` in your result line. I may have missed the translation, but seeing GRADI hints of gradians. 400 units to the full circle instead of 360. It'd be 200 / FUNCTION PI for gradians and not the 180 that gives degrees. – Brian Tiffin Jun 11 '20 at 08:38

1 Answers1

4

The 1.5042281 is the result in radian. So to get them in degree just divide the result with Pi and multiply with 180, giving you 86.1

Martheen
  • 5,198
  • 4
  • 32
  • 55