[linux-audio-dev] Traps in floating point code

Tim Goetze tim at quitte.de
Thu Jul 1 12:21:38 UTC 2004


[Ruben van Royen]

>The problem is that the rounding mode affects all floating point operations,
>such as multiply and divide. And normally you must do rounding and not
>truncation. Thus changing the mode will change the results, and a compiler is
>not allowed to do that.

yes, and it is wise to check if the results you obtain under the
manually changed rounding rule fit your spec.

>Only in very specific cases, such as a loop that converts an array float
>values to integers, where the truncation is the only floating point operation
>in the loop, is the compiler allowed to do the mode settings outside the
>loop. But I'm not sure if gcc does this.

i don't think it does, but the latest gcc i keep around is 3.0, and i
only use it to compare assembly output to 2.95 compilates.

afaik, the rounding mode handling is a peculiarity of the x86 arch,
and with gcc being a multi-arch compiler i can very well imagine the
gcc dev team omitting this special case.

tim



More information about the Linux-audio-dev mailing list