****************************************
      * Program name: hmathfuncs.cbl
      * This program demonstrates several of
      * the higher math functions that can
      * be used with the COMPUTE command.
      *
      * Copyright 2000 Deskware, Inc.
      ****************************************                                                             
       1 num_var             PIC -----.99.
       1 sign_var            PIC S9.
       1 exp_var             PIC --.999999.
       1 conv_input          PIC S99.99.
       1 conv_output         PIC S99.99.

       COMPUTE num_var = ABS(-9).
       DISPLAY LINEFEED&`Absolute value of -9 = `&num_var.

       COMPUTE sign_var = sign(-5.5).
       DISPLAY `The sign_var of -5.5  is      ` & sign_var.
       COMPUTE sign_var = sign(5.5).
       DISPLAY `The sign_var of  5.5  is      ` & sign_var.
       COMPUTE sign_var = sign(0).
       DISPLAY `The sign_var of  0    is      ` & sign_var.

       COMPUTE num_var = rounded(5.5).
       DISPLAY ` 5.5 rounded      is   ` & num_var.
       COMPUTE num_var rounded = 5.5.
       DISPLAY ` 5.5 rounded` & LINEFEED &
                   ` (COBOL85 syntax) is   ` & num_var.
       COMPUTE num_var = rounded(-5.5).
       DISPLAY `-5.5 rounded      is   ` & num_var.

       MOVE 10.01 TO conv_input.
       COMPUTE conv_output = CEILING(conv_input).
       DISPLAY `Ceiling of `&conv_input&` is      `&conv_output.
       COMPUTE conv_output = floor(conv_input).
       DISPLAY `Floor of   `&conv_input&` is      `&conv_output.
       COMPUTE conv_input = -10.01.
       COMPUTE conv_output = CEILING(conv_input).
       DISPLAY `Ceiling of `&conv_input&` is      `&conv_output.
       COMPUTE conv_output = floor(conv_input).
       DISPLAY `Floor of   `&conv_input&` is      `&conv_output.

       COMPUTE exp_var = exp(1).
       DISPLAY LINEFEED & `e to the power of 1         is   `&exp_var. 

       COMPUTE num_var = LN(exp(3)).
       DISPLAY `The natural log of` & LINEFEED &
               ` e to the power of 3        is`&num_var. 

       COMPUTE num_var = LOG(1\5).
       DISPLAY `The log (base 10) of` & LINEFEED &
               ` 1 * (10 to the power of 5) is`&num_var. 

       COMPUTE num_var = sqrt(625).
       DISPLAY LINEFEED&`The square root of 625 is `&num_var.
       COMPUTE num_var = ROOT(32,5).
       DISPLAY `The fifth root of 32   is `&num_var.
       COMPUTE num_var = 32^(1/5).
       DISPLAY `32 to the (1/5) power  is `&num_var.