forums.silverfrost.com
Welcome to the Silverfrost forums

Author Message
Anonymous
Guest

Posted: Sun Dec 12, 2004 7:33 am    Post subject: Function precision: Double vs Extended

I'm having trouble using a function. My function is:

[pre]
FUNCTION f(x)
USE Constants
IMPLICIT NONE

REAL(KIND=q) :: f ! Function type
REAL(KIND=q), INTENT(IN) :: x ! Argument

f = x + EXP(x)

END FUNCTION f

[/pre]

The module Constants that is used is:

[pre]
MODULE Constants
IMPLICIT NONE

INTEGER, PARAMETER :: q = SELECTED_REAL_KIND(P=16) ! Extended

END MODULE Constants

[/pre]

In the main program I declare the variables:

[pre]
REAL(KIND=q), EXTERNAL :: f
REAL(KIND=q) :: p0, y0, y1, y2

[/pre]

Then if I assign the values,

[pre]
p0 = 0.0
y0 = f(p0)
y1 = 1.0 - y0
y2 = 1.0 - f(p0)

[/pre]

the result is that
 Code: y1 = 0.0
which is correct, but
 Code: y2 = 2.0
which is incorrect!

Yet if I change
 Code: q
in the Constants module to:

[pre]
INTEGER, PARAMETER :: q = SELECTED_REAL_KIND(P=15) ! Double

[/pre]

then the result is
 Code: y1 = y2 = 0.0
.

Why is this?

Note that I'm using FTN95 (FTN95/Win32 Ver. 4.6.0, Personal Edition) on a Windows XP machine with an Intel Pentium 4 processor.

Thank you.

Miguel.
Anonymous
Guest

 Posted: Thu Dec 23, 2004 6:02 am    Post subject: Function precision: Double vs Extended This seems to be fixed in version 4.7.0. - Miguel.
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First
 All times are GMT + 1 Hour Page 1 of 1

 Jump to: Select a forum Admin----------------Announcements FTN95----------------GeneralKBaseSupportSuggestionsClearWin+Plato64-bit FTN77----------------Support
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Powered by phpBB © 2001, 2005 phpBB Group