Linux-kernel mailing list archive 1998-31,: Re: floating-point abuse in 2.1.113

# Re: floating-point abuse in 2.1.113

Mikael Pettersson (mikpe@csd.uu.se)
Thu, 6 Aug 1998 11:36:38 +0200 (MET DST)

- Messages sorted by: [ date ][ thread ][ subject ][ author ]
- Next message: Carsten Gross: "Re: Data corruption using 2940U"
- Previous message: Herve REY: "Re: Compiling new kernel"
- Maybe in reply to: Mikael Pettersson: "floating-point abuse in 2.1.113"
- Next in thread: Andi Kleen: "Re: floating-point abuse in 2.1.113"
- Reply: Andi Kleen: "Re: floating-point abuse in 2.1.113"

On Wed, 5 Aug 1998, Rogier Wolff wrote:

> So, let us conclude that the original author might have though about
> it and concluded that only ints would go into the binary (if the
> compiler would properly optimize it), so that it wouldn't be a problem.
>
> Let's decide right now that this reasoning is "off limits" and should
> be avoided.
> ...
> Conclusion: Yes, you could use an FP calculation for an integer
> constant and get the compiler to convert to integer before creating
> the binary. However we don't want to depend on the compiler for
> this to happen ALL the time.....

Agreed. My reasons for doing away with those seemingly-innocent
FP constant expressions were:
1. They're not necessary, int math will do the job nicely.
2. Thou shalt not even think about using FP in kernel code.
Having FP constants around is poor style.
3. (Related to 2) Someone in the future might not understand the
compile-time-only aspect of the code and replace one of the
int or FP constants with a variable. Bad.
4. The C language doesn't guarantee this behaviour. While empirical
evidence suggests that gcc will evaluate FP constant expressions
at compile-time, this is really dodgey and beyond specs.
By Murphy's law, this _will_ break at some point.

/Mikael

-
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.altern.org/andrebalsa/doc/lkml-faq.html

- Next message: Carsten Gross: "Re: Data corruption using 2940U"
- Previous message: Herve REY: "Re: Compiling new kernel"
- Maybe in reply to: Mikael Pettersson: "floating-point abuse in 2.1.113"
- Next in thread: Andi Kleen: "Re: floating-point abuse in 2.1.113"
- Reply: Andi Kleen: "Re: floating-point abuse in 2.1.113"