Prev: doesn't wait the batch finished and cause error reading.
Next: Parallel computing introductory text
From: frank on 23 Nov 2009 21:36 On Sun, 22 Nov 2009 18:57:53 -0600, mecej4 wrote: [snip denormals] >> [0,0.5) = 1056964608 > > which is equal to 126 X 2^23. There are seven bits for the biased > exponent; 2^7=128, but then your numbers don't include +Inf and NaN. > >> [0.5,1) = 8388608 > which is exactly 2^23. The significand takes all possible values, while > the sign and biased exponent are fixed (because the range is 2^-1 to > 2^0). I read up on the model for real data when I last read fortran reference, but I didn't do anything with it. Does what I'm doing here have anything to do with the above numbers? dan(a)dan-desktop:~/source$ gfortran real7.f90 -Wall -Wextra -o out dan(a)dan-desktop:~/source$ ./out radix is 2 range is 37 dan(a)dan-desktop:~/source$ cat real7.f90 real x integer d, e x = .5 d = radix(x) e = range(x) print *, "radix is ", d print *, "range is ", e end program ! gfortran real7.f90 -Wall -Wextra -o out ! ./out >text1.txt dan(a)dan-desktop:~/source$ -- frank "Guns: yes, they are harmful."
From: Ron Shepard on 24 Nov 2009 00:50 In article <7n0859F3jle00U1(a)mid.individual.net>, frank <frank(a)example.invalid> wrote: > I was expecting it to split the difference: > > dan(a)dan-desktop:~/source$ gfortran real6.f90 -Wall -Wextra -o out > dan(a)dan-desktop:~/source$ ./out > 0.50000000 5.96046448E-08 > dan(a)dan-desktop:~/source$ cat real6.f90 > real x > x = .5 > print *, x, spacing(x) > end program Is that the right value to return for SPACING() for an argument of 0.5? From the specification of the function, I would have thought it should return the smaller number, 2.98E-08. I would not expect the average value to be returned, or split the difference, or anything like that. I would expect the difference to the nearest number to be returned, which is 2.98E-08, not 5.96E-08. I can think of several reasons why I might prefer the larger of the two differences to be returned, not the smaller, but that's not the way the function is defined. $.02 -Ron Shepard
From: steve on 24 Nov 2009 01:49 On Nov 23, 9:50 pm, Ron Shepard <ron-shep...(a)NOSPAM.comcast.net> wrote: > In article <7n0859F3jle0...(a)mid.individual.net>, > > frank <fr...(a)example.invalid> wrote: > > I was expecting it to split the difference: > > > dan(a)dan-desktop:~/source$ gfortran real6.f90 -Wall -Wextra -o out > > dan(a)dan-desktop:~/source$ ./out > > 0.50000000 5.96046448E-08 > > dan(a)dan-desktop:~/source$ cat real6.f90 > > real x > > x = .5 > > print *, x, spacing(x) > > end program > > Is that the right value to return for SPACING() for an argument of > 0.5? From the specification of the function, I would have thought > it should return the smaller number, 2.98E-08. > In F95, spacing(x) = b**(e - p) with the radix b, precision p and e exponent of x. For x = 0.5 and gfortran's default real kind, one has b = 2, e = 0, p = 24, which gives 5.96xxxe-08. Note, F2003 has a different but irrelevant definition of spacing(). -- steve
From: frank on 24 Nov 2009 23:00 On Mon, 23 Nov 2009 22:49:30 -0800, steve wrote: > In F95, spacing(x) = b**(e - p) with the radix b, precision p and e > exponent of x. For x = 0.5 and gfortran's default real kind, one has b > = 2, e = 0, p = 24, which gives 5.96xxxe-08. Note, F2003 has a > different but irrelevant definition of spacing(). What do you mean with "precision" here? dan(a)dan-desktop:~/source$ gfortran real8.f90 -Wall -Wextra -o out dan(a)dan-desktop:~/source$ ./out for sp : radix is 2 range is 37 p is 24.000000 for dp : radix is 2 range is 307 q is 52.999999854364731 dan(a)dan-desktop:~/source$ cat real8.f90 implicit integer(a-t) INTEGER, PARAMETER :: SP=SELECTED_REAL_KIND(6,37) INTEGER, PARAMETER :: DP=SELECTED_REAL_KIND(15,307) REAL(KIND=SP) :: x, p REAL(KIND=DP) :: y, q x = .5_sp y = .5_dp e = 0 d = radix(x) f = range(x) print *, " for sp :" print *, "radix is ", d print *, "range is ", f p = e - log(spacing(x))/(log(real(d))) print *, "p is ", p print *, " for dp :" g = radix(y) h = range(y) print *, "radix is ", g print *, "range is ", h q = e - log(spacing(y))/(log(real(g))) print *, "q is ", q end program ! gfortran real8.f90 -Wall -Wextra -o out dan(a)dan-desktop:~/source$ It looks like precision is 53 for dp on my machine. -- frank "Guns: yes, they are harmful."
First
|
Prev
|
Pages: 1 2 Prev: doesn't wait the batch finished and cause error reading. Next: Parallel computing introductory text |