- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
real*8 eps(4)
real*8 a,b,c,d
eps(1) = Z'4037CB020C49BA5E'
eps(2) = Z'403C1E76C8B43958'
eps(3) = Z'BFF943D46B26BF87'
eps(4) = Z'BFF943D46B26BF87'
write(*,'(z17.16)') eps(1)*eps(2) - eps(3)*eps(4)
a = Z'4037CB020C49BA5E'
b = Z'403C1E76C8B43958'
c = Z'BFF943D46B26BF87'
d = Z'BFF943D46B26BF87'
write(*,'(z17.16)') a*b-c*d
end
save this as t.f. I am using Intel fortran compiler for linux 7.1. if I compile this without any optimization like: ifc -O0 -o t t.f then the two outputs get the same. but if I do some optimitation, like: ifc -O2 -o t t.f then it gets different(the last bit). But in Java I always get the second output as I did some optimitation in fortran. And who can tell me which one is more accurate???
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This is hell for anybody trying to do numerics up to machine precision :( Is there any compiler flag that tells the FP-unit to knock it off and behave like any normal double-precision unit?
Cheers
Pedro
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Cheers and thanks
Pedro
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
program main
real*8 eps(4)
real*8 a,b,c,d
eps(1) = Z'4037CB020C49BA5E'
eps(2) = Z'403C1E76C8B43958'
eps(3) = Z'BFF943D46B26BF87'
eps(4) = Z'BFF943D46B26BF87'
write(*,'(z17.16)') eps(1)*eps(2) - eps(3)*eps(4)
a = eps(1)
b = eps(2)
c = eps(3)
d = eps(4)
write(*,'(z17.16)') a*b-c*d
end
I just assigned the value from array to single variables. Why? Now I want to get the same output in fortran and java, who can tell me how? and the "-mp" does not work, I don't why. after I used -mp the output will be both the unoptimized results, but I need the output like java!!! Or who can tell me how to make java output with the same as fortran? thanks a lot!
quan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
write(*,'(z17.16)') eps(1)*eps(2) - eps(3)*eps(4)
is evaluated with 80 bits, whereas with
a = eps(1)
b = eps(2)
c = eps(3)
d = eps(4)
write(*,'(z17.16)') a*b-c*d
the... Aha. I see your point. You're right, the difference in the two printed values is a bug :(
The reason you can't get the same results as with Java? That is what you get for using processors that do not conform to the IEEE double-precision specification :)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This is very strict! Thanks !
quan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have used these subroutines before to set the trapping behaviour, but this makes your fortran code non-portable :(
Steve, you're the Intel-guy :) What was the rationale for not having these values controlled by compiler switches?
Cheers and thanks
Pedro
P.S. the issue of losing/gaining a bit is purely academic. I'm more interested in the implications for numerical algorithms, i.e. termination criteria.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The Windows compilers have initialized the x87 mode to 53 bit precision for several years now. Until recently, the linux compilers did not, because this settingwill break C long double code and produce different results from other linux compiler defaults. Now that SSE2 code has become the usual option, the question is becoming moot. If you don't want 64-bit precision mode, except for C long double, use one of the SSE2 options.
I did see one of the recent ifort compilers setting 53-bit precision at startup, which surprised me. I think this is undesirable in view of the implication that it would break any C long double function which might be called later, unless you knew that GET/SETCONTROLFPQQ are available now in the linux compiler, and should be used in such cases.
Until recently, complex math functions, such as sin(), have been more accurate on linux than in Windows, due to the difference in precision mode setting.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page