Re: floating-point abuse in 2.1.113

Albert D. Cahalan (acahalan@cs.uml.edu)
Tue, 4 Aug 1998 18:50:13 -0400 (EDT)


>>> - v.rangelow=(int)(87.9*16);
>>> - v.rangehigh=(int)(107.8*16);
>>> + v.rangelow=(879*16)/10;
>>> + v.rangehigh=(1078*16)/10;
>>
>> How can that be a problem? Shouldn't the multiplication and cast
>> be evaluated at compile time, leaving only an int?
>
> The problem is the "." in 88.9, etc. This means "float".

Yes, of course. You have a literal float multiplied by a literal int.
The compiler should promote the int and multiply. After that, the compiler
should convert the result to an int, eliminating the cast. Then the compiler
should store that int value in the object file. Why not?

If this has anything to do with IEEE rounding modes, gross!
In that case, gcc needs a -flinux-kernel option. Maybe one of the
existing flags will make gcc optimize away the floating point math.
How about -ffast-math?

-
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