Home > freetb4matlab > fenv > fesetround.m



% Change the rounding mode of the floating point arithmetics.


function err = fesetround(mode)


% -*- texinfo -*-
% @deftypefn {Function File} {} fesetround (@var{mode})
% Change the rounding mode of the floating point arithmetics. 
% Following the IEEE-754 standard recommendation, modern processors, including x86 and x86_64 architectures, support changing the rounding direction of the floating point arithmetics. 
% Possible values of @var{mode} are 
% @table @samp
% @item 0
% Sets the rounding mode to @samp{towards zero}, i.e. @samp{truncate}
% @item 0.5
% Sets the rounding mode to @samp{nearest} (the standard mode)
% @item Inf
% Sets the rounding mode to @samp{up}, i.e. @samp{towards +infinity}
% @item -Inf
% Sets the rounding mode to @samp{down}, i.e. @samp{towards -infinity}
% @end table
% When successful, @code{fesetround} returns 0. It is always recommended to verify the result experimentally by calling the function @code{fetestenv}, which tests the rounding mode and the precision of the floating point arithmetics. 
% It is known that some numerical libraries may set their own rounding modes. Therefore @code{fesetround} may affect operations performed by numerical libraries called by Octave in a different way than it does the interpreted code. Calls to such numerical libraries may also cancel changes previously made by @code{fesetround}:
% @example
% fesetprec(1); fesetround(0); fetestenv
% @print{} Machine epsilon: 1.19209e-07
% @print{} Rounding mode:   0
% hilb(2)\ones(2,1); fetestenv
% @print{} Machine epsilon: 2.22045e-16
% @print{} Rounding mode:   0.5
% @end example
% (the above test has been run on an x86 32-bit system using Octave 3.0.2 package provided along with the Fedora 9 Linux distribution).
% A possible application of this function, following the idea by W. Kahan, is an experimental (in)stability analysis. Running some code with various settings of the floating point arithmetics may reveal some instability of the numerical algorithm being used in the code or reveal possible ill conditioning of the very problem being solved.
% Literature
% @enumerate 
% @item W. Kahan, 'How Futile are Mindless Assessments of Roundoff in Floating-Point Computation?', available on the Web: @indicateurl{http://www.cs.berkeley.edu/~wkahan/Mindless.pdf}.
% @item W. Kahan, 'Why I can Debug some Numerical Programs You can''t', available on the Web: @indicateurl{http://www.cs.berkeley.edu/~wkahan/Stnfrd50.pdf}.
% @item Intel 64 and IA-32 Architectures Software Developer's Manual, Volume 1: Basic Architecture, May 2007.
% @end enumerate
% @seealso{fetestenv, fesetprec, system_dependent, fe_system_dependent}
% @end deftypefn


This function calls: This function is called by:
Generated on Sat 16-May-2009 00:04:49 by m2html © 2003