From owner-freebsd-questions Mon Aug 19 10: 5:39 2002 Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B145C37B400 for ; Mon, 19 Aug 2002 10:05:34 -0700 (PDT) Received: from smtp.infracaninophile.co.uk (happy-idiot-talk.infracaninophile.co.uk [81.2.69.218]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6402E43E77 for ; Mon, 19 Aug 2002 10:05:33 -0700 (PDT) (envelope-from m.seaman@infracaninophile.co.uk) Received: from happy-idiot-talk.infracaninophile.co.uk (localhost [IPv6:::1]) by smtp.infracaninophile.co.uk (8.12.5/8.12.5) with ESMTP id g7JH5FQI010990; Mon, 19 Aug 2002 18:05:15 +0100 (BST) (envelope-from matthew@happy-idiot-talk.infracaninophile.co.uk) Received: (from matthew@localhost) by happy-idiot-talk.infracaninophile.co.uk (8.12.5/8.12.5/Submit) id g7JH59JL010989; Mon, 19 Aug 2002 18:05:09 +0100 (BST) Date: Mon, 19 Aug 2002 18:05:09 +0100 From: Matthew Seaman To: Mikhail Teterin Cc: Dan Nelson , Matthew Seaman , questions@FreeBSD.ORG Subject: Re: pow(3) on FreeBSD Message-ID: <20020819170509.GA10906@happy-idiot-talk.infracaninophi> References: <200208190413.g7J4DEcw051123@corbulon.video-collage.com> <20020819043012.GN74231@dan.emsphone.com> <200208191124.35129.mi+mx@aldan.algebra.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200208191124.35129.mi+mx@aldan.algebra.com> User-Agent: Mutt/1.5.1i Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Mon, Aug 19, 2002 at 11:24:35AM -0400, Mikhail Teterin wrote: > You are right, the FreeBSD's man-page does not specify the return value > in case of a non-integer y. I just know it from experiment to be zero > (and not NaN as Matthew claimed). That was a non-integer power of a *negative* number... Anyhow, the claim that NaN was returned was based on empirical evidence: happy-idiot-talk:~/misc:% cat xpow.c #include #include #include #include int main(int argc, char *argv[]) { double x; double y; double res; if (argc < 3) { fprintf(stderr, "%s", "Usage: pow x y\n"); exit(-1); } x = strtod(argv[1], NULL); y = strtod(argv[2], NULL); errno = 0; res = pow(x, y); if (errno) { perror("pow() error: "); } printf("%g ^ %g = %g\n", x, y, res); exit(0); } /* Compile: cc -o xpow xpow.c -lm */ happy-idiot-talk:~/misc:% cc -o xpow xpow.c -lm happy-idiot-talk:~/misc:% ./xpow -1 0.5 -1 ^ 0.5 = NaN Mind you, there's also the mysterious case of the errno that didn't bark in the night. This is: happy-idiot-talk:~/misc:% uname -v FreeBSD 4.6-STABLE #3: Sat Aug 17 20:32:01 BST 2002 matthew@happy-idiot-talk.infracaninophile.co.uk:/usr/obj/usr/src/sys/HAPPY-IDIOT-TALK running on: happy-idiot-talk:~/misc:% grep CPU /var/run/dmesg.boot CPU: AMD Athlon(TM) XP1600+ (1400.06-MHz 686-class CPU) Cheers, Matthew -- Dr Matthew J Seaman MA, D.Phil. 26 The Paddocks Savill Way Tel: +44 1628 476614 Marlow Fax: +44 0870 0522645 Bucks., SL7 1TH UK To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message