Re: Change FPU round mode



On Nov 02, 2009 05:34, steve wrote:
On Nov 1, 7:20 pm, Yipkei Kwok <yipkeik...@xxxxxxxxx> wrote:
The default x87 FPU rounding mode is `round to the nearest'.

Is there any Fortran command that I can use to change the rounding
mode to `round to 0'?

Not with gfortran. gfortran doesn't support the IEEE 754 intrinsic
module, yet.

I want to add for completeness: If you only want to round the I/O
(writing, output),* GCC 4.5 supports the ROUND= keyword and the R* edit
descriptors of Fortran 2003. This does not help, however with doing the
calculations with the desired rounding.

But if such a command is not available, I know how to change the
rounding mode using assembly instructions. Is there any way to inline
assembly code in Fortran code with the gfortran compiler?
Newer versions of gfortran support the ISO C binding facility. You
could bind to the fenv functions to toggle the rounding mode.

I think gfortran does not touch the rounding thus doing it by calling
fesetround - either directly or by calling a C program which does this
call (or using assembler) should works.

I suspect that libgfortran assumes round-to-nearest.

I think libgfortran does not assume any specific rounding and should
work in principle correctly independing of the rounding. Though there
might be bugs, due to the implicit assumption of one way of rounding.

Tobias

* I wonder how many compilers support rounding on reading/input, e.g.
for reading "0.1" leading to a binary FP number being >0.1 or <0.1.
.



Relevant Pages

  • Re: XQ and ->Qpi bug on large X
    ... you shouldn't be rounding to only two digits ... I am trying to make a similar point here about rounding; ... and round it, ... prior to using the input values in calculations. ...
    (comp.sys.hp48)
  • Re: My Completed RATECRYPT() function included below
    ... I was interested because most rounding functions do not round in an unbiased manner. ... I have seen various reports of clipper rounding problems but there are many different rounding methods and clipper chose a common one. ... The gaussian method (an unbiased estimator) gives the same answer you would get using a standard c compiler and printed with printf. ...
    (comp.lang.clipper)
  • Re: Rounding question
    ... Very many thanks for your help, Joe. ... It would be nice to get Excel to default to rounding, however I'll take one step at a time... ... you probably want to use ROUND whenever the result should be dollars and cents or any other specific number of decimal places. ... And although the number formats are set to 2 dp, this evidently only applies to the display! ...
    (microsoft.public.excel)
  • Re: XQ and ->Qpi bug on large X
    ... plot of all specific values resembling a "normal distribution" ... we should round each value ... which fails if we start computing "mean square" ... the moment we begin rounding data, we make the data less reliable ...
    (comp.sys.hp48)
  • Re: Rounding errors
    ... DO NOT add up the rounded amounts for the ... That's what I meant by "rounding intermediate results." ... Since we, as receiver of the report, lack access to unrounded detail, ... >thousands that do add up is the 'round and forward' that I described. ...
    (comp.lang.cobol)