View previous topic :: View next topic
|
Author |
Message |
yuvaraj_d Warnings : 2 New User
Joined: 11 Dec 2006 Posts: 2 Location: bangalore
|
|
|
|
I'm looking for an algorithm for the square root. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
If you're coding in COBOL, there is a SQRT (square root) funtion.
From the IBM COBOL manual. . . .
Quote: |
The SQRT function returns a numeric value that approximates the square root of the argument specified. The function type is numeric.
FUNCTION SQRT ( argument-1 )
argument-1 Must be class numeric. The value of argument-1 must be zero or positive. The returned value is the absolute value of the approximation of the square root of argument-1. |
|
|
Back to top |
|
|
ofer71
Global Moderator
Joined: 27 Dec 2005 Posts: 2358 Location: Israel
|
|
|
|
Have you tried to use Google for the keywords square root algorithm pseudocode?
O. |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
As far as algorithns go, long division is just guess a multiplier and subtract to see if it was too high or too low...grin...
I'd imagine that guess a root and subtract could be used also? |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
Why an algorithm? How about this:
COMPUTE WS-SQRT = (WS-NBR ** .5)
Don't forget to define WS-SQRT with decimal places. |
|
Back to top |
|
|
|