I learned that fesetround
can be used to control FP rounding rule.
I wonder what is scope of the function? say, is it local to the very source file? or translation unit? how about thread?
Any insight will be greatly appreciated.
As you can see in the Floating-point environment reference:
The floating-point environment is the set of floating-point status flags and control modes supported by the implementation. It is thread-local, each thread inherits the initial state of its floating-point environment from the parent thread.
(emphasis is mine)
This applies to several floating point functions which are listed there, including fesetround
.
As @TedLyngmo commented it is similarly specified in the standard (see article 7.6.3):
The dynamic floating-point environment has thread storage duration.
(emphasis is mine)
I.e. the scope is the current thread.