home *** CD-ROM | disk | FTP | other *** search
/ Software Du Jour / SoftwareDuJour.iso / BUSINESS / DBASE / DBAPG.ARC / SQROOT.PRG < prev    next >
Encoding:
Text File  |  1984-08-12  |  768 b   |  27 lines

  1. * Program.: SQROOT.PRG
  2. * Author..: Kelly Mc Tiernan
  3. * Date....: 12/15/83
  4. * Notice..: Copyright 1983, Kelly Mc Tiernan, All Rights Reserved
  5. * Version.: dBASE II, version 2.4x
  6. * Notes...: Calculates the square root of a number.
  7. *         
  8. *    IN: number-N-10
  9. *   OUT: root-N-10-5
  10. *
  11. STORE number TO root
  12. DO CASE
  13.    CASE number < 0
  14.       ? "ERROR - CANNOT TAKE THE SQUARE ROOT "+;
  15.         "OF A NUMBER < 0"
  16.       CANCEL
  17.    CASE number > 0
  18.       STORE (0.5 * ( root + number / root )) TO root
  19.       DO WHILE (root * root) > number
  20.          STORE (0.5 * ( root + number / root )) TO root
  21.       ENDDO
  22.       * ---Round off to 5 decimal places.
  23.       STORE INT( root * 100000 + .5 ) / 100000.00000 TO root
  24. ENDCASE
  25. RETURN
  26. * EOF: SQROOT.PRG
  27.