[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
## Re: Switch rounding mode

**From**: |
Przemek Klosowski |

**Subject**: |
Re: Switch rounding mode |

**Date**: |
Fri, 17 Apr 2009 12:08:50 -0400 (EDT) |

If you prefer another example [c]=[a]+[b]
> c.min = a.min \+/ b.min
> c.max = a.max /+\ b.max
\+/ and /+\ are + operator with rounding downward for the first and
upward for the second.
And my question is the same : how I do this operator (\+/ and /+\).
In my opinion, the motivation for interval computing results from
physical indeterminacy of inputs (e.g. temperature measured to within
.01 degree). Such physical uncertainity intervals are significantly
larger than numerical effects, so the effect of the rounding mode used
in calculation should be negligible.
Having said that, C99 and later floating point library standards
provide fesetround() functionality, which changes the rounding mode
(if supported by the FP hardware, of course). In Octave, you could
write an .oct wrapper that calls fesetround() before your expression:
fesetround(FE_DOWNWARD) ; c.min = a.min + b.min
fesetround(FE_UPWARD) ; c.max = a.max + b.max
fesetround(FE_DFL_ENV);