Path: utzoo!utgpu!cunews!cognos!alzabo!andras From: andras@alzabo.uucp (Andras Kovacs) Newsgroups: comp.lang.c Subject: integer square root rounding Message-ID: <1990Oct4.044055.24389@alzabo.uucp> Date: 4 Oct 90 04:40:55 GMT Reply-To: andras@alzabo.UUCP (Andras Kovacs) Distribution: na Organization: Brian's XENIXlings, Ottawa, Canada Lines: 27 I apologize if it is not the proper newsgroup to ask but I need help. I implemented the Newton-Raphson method to calculate integer square root with the following code: int Sqr(int param) { int guess = 1, tmp; do { tmp = guess; guess = (guess + param / guess) / 2; } while (tmp != guess); return guess; } (Actually, I wrote it in ARM assembly but this is the idea.) Now the problem is that this code rounds DOWN to the closest integer; can someone tell me how to modify it to get properly rounded results? Please reply through E-mail. Thanks Andras Kovacs "Don't have a cow, man!" (Attributed to Bart Simpson)