fix FLT_ROUNDS to reflect the current rounding mode
Implemented as a wrapper around fegetround introducing a new function to the ABI: __flt_rounds. (fegetround cannot be used directly from float.h)
This commit is contained in:
committed by
Rich Felker
parent
bd67959f3a
commit
559de8f5f0
@@ -0,0 +1,19 @@
|
||||
#include <float.h>
|
||||
#include <fenv.h>
|
||||
|
||||
int __flt_rounds()
|
||||
{
|
||||
switch (fegetround()) {
|
||||
#ifdef FE_TOWARDZERO
|
||||
case FE_TOWARDZERO: return 0;
|
||||
#endif
|
||||
case FE_TONEAREST: return 1;
|
||||
#ifdef FE_UPWARD
|
||||
case FE_UPWARD: return 2;
|
||||
#endif
|
||||
#ifdef FE_DOWNWARD
|
||||
case FE_DOWNWARD: return 3;
|
||||
#endif
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
Reference in New Issue
Block a user