Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Fortran > Are f.p. manipu...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 42 Topic 8183 of 8775
Post > Topic >>

Are f.p. manipulation functions only used in initialization?

by "James Van Buskirk" <not_valid@[EMAIL PROTECTED] > Apr 26, 2008 at 02:43 PM

I was writing some code with gfortran and found that spacing only
worked in initialization expressions.  Doesn't anyone else use the
floating point manipulation functions in ordinary expressions and
specification expressions?  Testing with gfortran I found that
RRSPACING, SCALE, SET_EXPONENT, and, SPACING were broken like this,
while EXPONENT, FRACTION, and NEAREST seemed to work:

C:\gfortran\james\archpi>c:\gfortran\win64\bin\x86_64-pc-mingw32-gfortran
-v
Using built-in specs.
Target: x86_64-pc-mingw32
Configured with: 
.../../trunk/configure --prefix=/home/FX/irun64 --build=i586-pc-
mingw32 --target=x86_64-pc-mingw32 --with-gmp=/home/FX/local
--enable-languages=
c,fortran --disable-werror --disable-nls --enable-threads
Thread model: win32
gcc version 4.4.0 20080421 (experimental) [trunk revision 134506] (GCC)

C:\gfortran\james\archpi>type spacing_bug.f90
program spacing_bug
   implicit none
   real, parameter :: x1 = 3.14159265358979
   integer, parameter :: ulps1 = 2
   real, parameter :: y1 = ulps1*spacing(x1) ! Only f03
   real, parameter :: y2 = rrspacing(x1) ! Only f03
   real, parameter :: y3 = scale(x1,ulps1) ! Only f03
   real, parameter :: y4 = set_exponent(x1,ulps1) ! Only f03
   real x
   integer ulps

   write(*,*) 'ulps1*spacing(x1) = ', y1
   write(*,*) 'rrspacing(x1) = ', y2
   write(*,*) 'scale(x1,ulps1) = ', y3
   write(*,*) 'set_exponent(x1,ulps1) = ', y4
   x = x1
   ulps = ulps1
   call sub(x,ulps)
end program spacing_bug

subroutine sub(x,ulps)
   implicit none
   real x
   integer ulps
   integer j1(int(ulps*spacing(x)))
   integer j2(int(rrspacing(x))/100000)
   integer j3(int(scale(x,ulps)))
   integer j4(int(set_exponent(x,ulps)))

   write(*,*) 'ulps*spacing(x) = ', ulps*spacing(x)
   write(*,*) 'rrspacing(x) = ', rrspacing(x)
   write(*,*) 'scale(x,ulps) = ', scale(x,ulps)
   write(*,*) 'set_exponent(x,ulps) = ', set_exponent(x,ulps)
   write(*,*) 'size(j1) = ', size(j1)
   write(*,*) 'size(j2) = ', size(j2)
   write(*,*) 'size(j3) = ', size(j3)
   write(*,*) 'size(j4) = ', size(j4)
end subroutine sub

C:\gfortran\james\archpi>c:\gfortran\win64\bin\x86_64-pc-mingw32-gfortran 
spacin
g_bug.f90 -ospacing_bug

C:\gfortran\james\archpi>spacing_bug
 ulps1*spacing(x1) =   4.76837158E-07
 rrspacing(x1) =    13176795.
 scale(x1,ulps1) =    12.566371
 set_exponent(x1,ulps1) =    3.1415927
 ulps*spacing(x) =    2.0000000
 rrspacing(x) =    3.1415927
 scale(x,ulps) =    3.1415927
 set_exponent(x,ulps) =   0.78539819
 size(j1) =            2
 size(j2) =            0
 size(j3) =            3
 size(j4) =            0

-- 
write(*,*) transfer((/17.392111325966148d0,6.5794487871554595D-85, &
6.0134700243160014d-154/),(/'x'/)); end
 




 42 Posts in Topic:
Are f.p. manipulation functions only used in initialization?
"James Van Buskirk&q  2008-04-26 14:43:52 
Re: Are f.p. manipulation functions only used in initialization?
kargl@[EMAIL PROTECTED]   2008-04-26 21:52:30 
Re: Are f.p. manipulation functions only used in initialization?
"James Van Buskirk&q  2008-04-26 16:24:59 
Re: Are f.p. manipulation functions only used in initialization?
"James Van Buskirk&q  2008-04-26 20:55:30 
Re: Are f.p. manipulation functions only used in initialization?
Charles Coldwell <cold  2008-04-27 13:00:43 
Re: Are f.p. manipulation functions only used in initialization?
"James Van Buskirk&q  2008-04-27 13:53:14 
Re: Are f.p. manipulation functions only used in initialization?
lindahl@[EMAIL PROTECTED]  2008-04-28 17:25:49 
Re: Are f.p. manipulation functions only used in initialization?
kargl@[EMAIL PROTECTED]   2008-04-26 22:54:20 
Re: Are f.p. manipulation functions only used in initialization?
"Anony" <inv  2008-04-26 23:25:57 
Re: Are f.p. manipulation functions only used in initialization?
"James Van Buskirk&q  2008-04-26 20:10:58 
Re: Are f.p. manipulation functions only used in initialization?
"Anony" <inv  2008-04-27 12:34:46 
Re: Are f.p. manipulation functions only used in initialization?
"FX" <couder  2008-04-27 18:37:33 
Re: Are f.p. manipulation functions only used in initialization?
Tobias Burnus <burnus@  2008-04-27 01:25:20 
Re: Are f.p. manipulation functions only used in initialization?
"James Van Buskirk&q  2008-04-27 03:32:59 
Re: Are f.p. manipulation functions only used in initialization?
"FX" <couder  2008-04-27 18:39:17 
Re: Are f.p. manipulation functions only used in initialization?
"James Van Buskirk&q  2008-04-30 11:17:01 
Re: Are f.p. manipulation functions only used in initialization?
Dan Nagle <dannagle@[E  2008-04-30 22:18:33 
Re: Are f.p. manipulation functions only used in initialization?
"FX" <couder  2008-04-30 22:54:21 
Re: Are f.p. manipulation functions only used in initialization?
Dan Nagle <dannagle@[E  2008-05-01 00:14:51 
Re: Are f.p. manipulation functions only used in initialization?
"FX" <couder  2008-05-01 08:06:56 
Re: Are f.p. manipulation functions only used in initialization?
lindahl@[EMAIL PROTECTED]  2008-04-30 17:53:08 
Re: Are f.p. manipulation functions only used in initialization?
"James Van Buskirk&q  2008-04-30 21:37:03 
Re: Are f.p. manipulation functions only used in initialization?
Dan Nagle <dannagle@[E  2008-05-01 10:19:46 
Re: Are f.p. manipulation functions only used in initialization?
Dan Nagle <dannagle@[E  2008-04-30 22:20:37 
Re: Are f.p. manipulation functions only used in initialization?
"FX" <couder  2008-05-02 08:38:14 
Re: Are f.p. manipulation functions only used in initialization?
"James Van Buskirk&q  2008-05-03 13:16:15 
Re: Are f.p. manipulation functions only used in initialization?
"FX" <couder  2008-05-04 10:46:43 
Re: Are f.p. manipulation functions only used in initialization?
"James Van Buskirk&q  2008-05-05 15:53:39 
Re: Are f.p. manipulation functions only used in initialization?
"James Van Buskirk&q  2008-05-05 18:24:42 
Re: Are f.p. manipulation functions only used in initialization?
Janne Blomqvist <foo@[  2008-05-06 11:05:35 
Re: Are f.p. manipulation functions only used in initialization?
"James Van Buskirk&q  2008-05-06 04:01:57 
Re: Are f.p. manipulation functions only used in initialization?
Janne Blomqvist <foo@[  2008-05-06 20:32:14 
Re: Are f.p. manipulation functions only used in initialization?
"James Van Buskirk&q  2008-05-06 13:50:09 
Re: Are f.p. manipulation functions only used in initialization?
"James Van Buskirk&q  2008-05-06 14:37:04 
Re: Are f.p. manipulation functions only used in initialization?
"FX" <couder  2008-05-06 21:04:28 
Re: Are f.p. manipulation functions only used in initialization?
"James Van Buskirk&q  2008-05-06 15:46:35 
Re: Are f.p. manipulation functions only used in initialization?
Ron Ford <ron@[EMAIL P  2008-05-06 17:34:28 
Re: Are f.p. manipulation functions only used in initialization?
"James Van Buskirk&q  2008-05-10 13:34:10 
Re: Are f.p. manipulation functions only used in initialization?
kargl@[EMAIL PROTECTED]   2008-04-27 20:30:26 
Re: Are f.p. manipulation functions only used in initialization?
"FX" <couder  2008-04-27 22:12:09 
Re: Are f.p. manipulation functions only used in initialization?
Charles Coldwell <cold  2008-04-28 10:46:00 
Re: Are f.p. manipulation functions only used in initialization?
kargl@[EMAIL PROTECTED]   2008-05-01 05:05:52 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Mon Oct 13 8:41:04 CDT 2008.