Date: Sun, 13 Jun 2004 18:29:07 +0200 From: Stefan Farfeleder <stefanf@FreeBSD.org> To: freebsd-standards@freebsd.org Subject: Re: sign of infinity and isinf()? Message-ID: <20040613162903.GO715@wombat.fafoe.narf.at> In-Reply-To: <20040613160630.GB12116@troutmask.apl.washington.edu>
index | next in thread | previous in thread | raw e-mail
On Sun, Jun 13, 2004 at 09:06:30AM -0700, Steve Kargl wrote:
> I don't have a copy of the C99 standard only Harbison and Steele,
> 5th Ed. On page 440, they state: "The isinf macro returns a nonzero
> value if and only if its argument is infinite (with any sign)."
This is what C99 says:
# Description
# The isinf macro determines whether its argument value is an infinity
# (positive or negative). First, an argument represented in a format
# wider than its semantic type is converted to its semantic type. Then
# determination is based on the type of the argument.
# Returns
# The isinf macro returns a nonzero value if and only if its argument
# has an infinite value.
I agree that the text from H&S is a bit ambiguous.
> The program below does note return the sign.
> kargl[243] gcc -o a -O a.c
> kargl[244] ./a
> -inf
> 1
> #include <stdio.h>
> #include <math.h>
>
> int main(void) {
> double x, y;
> x = -1.;
> y = 0.;
> x /= y;
> printf("%lf\n", x);
> printf("%d\n", isinf(x));
> }
Since 1 is a nonzero value, this is correct.
Cheers,
Stefan
help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040613162903.GO715>
