Displaying 2 results from an estimated 2 matches for "forceroundup".
2017 Nov 04
2
FW: clarification needed for the constrained fp implementation.
...he environment
> (fesetround, fegetround, fetestexcept, etc.) but you can only
> safely use these if you have set FENV_ACCESS to the “on” state. A
> typical usage might look like this:
>
> #include <fenv.h>
>
> double someFunc(double A, double B, bool ForceRoundUp) {
>
> #pragma STDC FENV_ACCESS ON
>
> double Result;
>
> if (ForceRoundUp) {
>
> int OldRM = fegetround();
>
> fesetround(FE_UPWARD);
>
> Result = A/B;
>
> fesetround(OldRM);
>
> } else {
>
>...
2017 Nov 03
2
FW: clarification needed for the constrained fp implementation.
...standard provides library calls to access the environment (fesetround, fegetround, fetestexcept, etc.) but you can only safely use these if you have set FENV_ACCESS to the "on" state. A typical usage might look like this:
#include <fenv.h>
double someFunc(double A, double B, bool ForceRoundUp) {
#pragma STDC FENV_ACCESS ON
double Result;
if (ForceRoundUp) {
int OldRM = fegetround();
fesetround(FE_UPWARD);
Result = A/B;
fesetround(OldRM);
} else {
Result = A/B;
}
return Result;
}
So you see here that there are explicit calls to change the rounding mode....