Re: Floating point in kernel

From: Ron Flory (ron.flory@adtran.com)
Date: Mon May 08 2000 - 08:41:52 EST


> > foo = some_other_ulong * 1234;
> > ^__ sequence point
> > foo /= 1000;
>
> As far as I know this is not needed at all.
> * and / have the same precedence and associativity is specified from
> left to right so this is interpreted as:
>
> foo = (some_other_ulong * 1234) / 1000
>
> It's not guaranted that some_other_ulong * 1234 is evaluated before 1000
> but we are sure that multiplication is done before division.
>
> If I'm wrong I'd like to know ASAP as I've written bogus C code for 15
> years now ;-))

 Its a matter of what compiler/optimizer you are using, and how portable
you want to be. I have personally seen at least two commercial
compilers return -very- bogus results for situations exactly like this
unless the statements above are seperated onto different lines.

ron

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Mon May 15 2000 - 21:00:11 EST