Chris,
As all have said, your missing the return.
Another mistake in my opinion is using == with floats.
You cannot depend on that to work.
This is just the nature of floating point numbers. In your case b is probably
20.01 or something like it.
The printf is showing 20.00 b
On 14 Jun 2002, Guillaume Cottenceau wrote:
> Chris Rode <[EMAIL PROTECTED]> writes:
>
> [...]
>
> > float toot(int x, float y) {
> >if (y == 20) {
> > return y;
> >} else {
> > toot(x, x*y); (**)
> >}
> > }
> >
> >
> > Compiled with Red Hat's gcc 2.96, I
Chris,
As all have said, your missing the return.
Another mistake in my opinion is using == with floats.
You cannot depend on that to work.
This is just the nature of floating point numbers. In your case b is probably
20.01 or something like it.
The printf is showing 20.00 b
>
> float toot(int x, float y) {
>if (y == 20) {
> return y;
>} else {
> toot(x, x*y);
>}
> }
The code itself is broken as other have said you need:
return(toot(x, x*y));
The reason it ever did work has to do with the internal mechanics
of how function calls are
Chris Rode <[EMAIL PROTECTED]> writes:
[...]
> float toot(int x, float y) {
>if (y == 20) {
> return y;
>} else {
> toot(x, x*y); (**)
>}
> }
>
>
> Compiled with Red Hat's gcc 2.96, I get "nan" (however, If I take out
> the recursive call, and just return
> I'm honestly not trying to resurrect some gcc 2.96 flame war or anything
> here, but I'm not a very seasoned C programmer, and I've run across an
> inconsistancy between Red Hat's version of gcc, and gcc 2.95.4 on a Debian
> system. Consider the following uninspired, pointless piece of code:
Dear Chris,
Your recurse statment should read :
return (toot (x, x * y));
instead of just :
toot (x, x * y);
Regards,
Raymond
Chris Rode wrote:
> I'm honestly not trying to resurrect some gcc 2.96 flame war or anything
> here, but I'm not a very seasoned C programmer, and I've run
I'm honestly not trying to resurrect some gcc 2.96 flame war or anything
here, but I'm not a very seasoned C programmer, and I've run across an
inconsistancy between Red Hat's version of gcc, and gcc 2.95.4 on a Debian
system. Consider the following uninspired, pointless piece of code:
#inclu