IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Need algorithm for the square root


IBM Mainframe Forums -> Mainframe Interview Questions
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
yuvaraj_d
Warnings : 2

New User


Joined: 11 Dec 2006
Posts: 2
Location: bangalore

PostPosted: Mon Dec 11, 2006 9:13 pm
Reply with quote

I'm looking for an algorithm for the square root.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Mon Dec 11, 2006 9:31 pm
Reply with quote

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
View user's profile Send private message
ofer71

Global Moderator


Joined: 27 Dec 2005
Posts: 2358
Location: Israel

PostPosted: Tue Dec 12, 2006 4:14 am
Reply with quote

Have you tried to use Google for the keywords square root algorithm pseudocode?

O.
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Tue Dec 12, 2006 4:29 am
Reply with quote

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
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Wed Dec 13, 2006 9:47 am
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> Mainframe Interview Questions

 


Similar Topics
Topic Forum Replies
No new posts Root Segments order IMS DB/DC 2
No new posts Byte conversion Algorithm COBOL Programming 6
No new posts Algorithm to unpack ISPF PACKED format TSO/ISPF 21
No new posts Expanding only root segments from len... IMS DB/DC 11
No new posts COBOL match file algorithm COBOL Programming 7
Search our Forums:

Back to Top