Re: Change FPU round mode
- From: Tobias Burnus <burnus@xxxxxxxx>
- Date: Mon, 02 Nov 2009 09:13:43 +0100
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 theNewer versions of gfortran support the ISO C binding facility. You
rounding mode using assembly instructions. Is there any way to inline
assembly code in Fortran code with the gfortran compiler?
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.
.
- Follow-Ups:
- Re: Change FPU round mode
- From: steve
- Re: Change FPU round mode
- From: nmm1
- Re: Change FPU round mode
- References:
- Change FPU round mode
- From: Yipkei Kwok
- Re: Change FPU round mode
- From: steve
- Change FPU round mode
- Prev by Date: Re: Change FPU round mode
- Next by Date: Re: Change FPU round mode
- Previous by thread: Re: Change FPU round mode
- Next by thread: Re: Change FPU round mode
- Index(es):
Relevant Pages
|