problem with very small numbers - g95 versus gfortran
- From: e p chandler <epc8@xxxxxxxx>
- Date: Wed, 28 May 2008 10:53:16 -0700 (PDT)
This is related to a different thread in which the OP claimed that
numbers set to 0 were being displayed as approx. e-309.
While playing with numbers in this range, I encountered what appears
to be a bug in g95. (See Google's gg95)
Apparently there is a problem with assigning a very small double
precision literal to a 10-byte real. (MinGW on Win32). Assigning a
literal of the proper kind resolves the problem.
Of course I realize that assigning a real constant to a double
precision variable, etc. may result in loss of precision, but in this
case it seems more like a real error. It looks like a bit gets dropped
near 1e-308.
Program listing:
C:\temp>type x.f95
real*10 x,y
x=1d-306
y=1e-306_10
print *,306,x,y
print '(2(e30.20e4,/))',x,y
x=1d-307
y=1e-307_10
print *,307,x,y
print '(2(e30.20e4,/))',x,y
x=1d-308
y=1e-308_10
print *,308,x,y
print '(2(e30.20e4,/))',x,y
end
Output:
C:\temp>g95 x.f95
C:\temp>a
306 1.0000000000000000279E-306 1.E-306
0.10000000000000000279E-0305
0.10000000000000000000E-0305
307 9.999999999999999093E-308 1.E-307
0.99999999999999990933E-0307
0.10000000000000000000E-0306
308 4.9999999999999995466E-309 1.E-308
0.49999999999999995466E-0308
0.99999999999999999997E-0308
C:\temp>gfortran x.f95
C:\temp>a
306 1.00000000000000002790E-0306
1.00000000000000000003E-0306
0.10000000000000000279E-0305
0.10000000000000000000E-0305
307 9.99999999999999909327E-0308
1.00000000000000000003E-0307
0.99999999999999990933E-0307
0.10000000000000000000E-0306
308 9.99999999999999909327E-0309
9.99999999999999999974E-0309
0.99999999999999990933E-0308
0.99999999999999999997E-0308
Versions:
C:\temp>g95 -v
Using built-in specs.
Target:
Configured with: /src/G95/gcc-4.1.2/configure --prefix=/mingw --enable-
languages
=c --with-ld=/mingw/bin/ld --with-as=/mingw/bin/as --host=i386-pc-
mingw32 --enab
le-threads --disable-nls --disable-win32-registry --enable-sjlj-
exceptions --ena
ble-libgcj --without-x
Thread model: win32
gcc version 4.1.2 (g95 0.92!) May 15 2008
C:\temp>gfortran -v
Using built-in specs.
Target: i586-pc-mingw32
Configured with: ../trunk/configure --prefix=/mingw --enable-
languages=c,fortran
--with-gmp=/home/FX/local --with-ld=/mingw/bin/ld --with-as=/mingw/
bin/as --dis
able-werror --enable-bootstrap --enable-threads --disable-nls --
build=i586-pc-mi
ngw32 --enable-libgomp --disable-shared
Thread model: win32
gcc version 4.4.0 20080514 (experimental) [trunk revision 135286]
(GCC)
- e
.
- Follow-Ups:
- Re: problem with very small numbers - g95 versus gfortran
- From: James Van Buskirk
- Re: problem with very small numbers - g95 versus gfortran
- Prev by Date: Re: How to do AINS() and ADEL()
- Next by Date: Gfortran 4.4 binary (OpenMP and 64bit capability) for PPC Tiger
- Previous by thread: Foray Build Tool Project Started
- Next by thread: Re: problem with very small numbers - g95 versus gfortran
- Index(es):
Relevant Pages
|
|