delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/03/17/02:31:44

From: Jack Klein <jackklein AT spamcop DOT net>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Whats up with sqrt?
Message-ID: <5k36bt4lb6o4gnjqok4ijokhs5kce193b5@4ax.com>
References: <5BF60CD649EDD411A04600B0D049F53A09257B AT hydmail02 DOT hyd DOT wilco-int DOT com> <8ugkfne00UjFETbF0i AT andrew DOT cmu DOT edu>
X-Newsreader: Forte Agent 1.8/32.548
MIME-Version: 1.0
Lines: 44
Date: Sat, 17 Mar 2001 07:15:38 GMT
NNTP-Posting-Host: 12.75.159.31
X-Complaints-To: abuse AT worldnet DOT att DOT net
X-Trace: bgtnsc05-news.ops.worldnet.att.net 984813338 12.75.159.31 (Sat, 17 Mar 2001 07:15:38 GMT)
NNTP-Posting-Date: Sat, 17 Mar 2001 07:15:38 GMT
Organization: AT&T Worldnet
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

On Sat, 17 Mar 2001 01:57:55 -0500 (EST), James W Sager Iii
<sager+@andrew.cmu.edu> wrote in comp.os.msdos.djgpp:

> Excerpts from netnews.comp.os.msdos.djgpp: 17-Mar-101 RE: Whats up with
> sqrt? by Prashant Ramachandra AT wil 
> >  
> > On Saturday, March 17, 2001 10:49 AM, James W Sager Iii
> > [SMTP:sager+@andrew.cmu.edu] wrote:
> > | For me, the function sqrt() which obviously returns a square root
> > | is
> > | messing up for me on moderately large numbers.
> > | 
> > | anything below 10,000 and it gives me about the right answer, but at
> > | like:
> > | 
> > | range = sqrt(300,000)
> > | 
> > | I get a 0 as a return value?  I tried doing:
> >  
> > Don't use commas while sending parameters. It's giving you the square root
> > of the second parameter, i.e. 0.
> >  
> > range = sqrt (300000.0);
> >  
> > is the right way to do it.
> 
> I'm sorry, I wasn't using commas... but at the same time I wasn't using
> 0. so perhaps it was being type casted wrong.
> 
> but I tested it
> a=sqrt(10001.0);
> 
> returns 100516
> 
> Ok, that makes no sense what so ever
> well at least I have my own function to do it no biggie

Have you included <math.h> in the source code file?  If not, do so.
If so, add it.  What is the type of a?  Post the smallest real code
that compiles and shows the problem.

-- 
Jack Klein
Home: http://JK-Technology.Com

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019