forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Function precision: Double vs Extended

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support
View previous topic :: View next topic  
Author Message
Anonymous
Guest





PostPosted: Sun Dec 12, 2004 7:33 am    Post subject: Function precision: Double vs Extended Reply with quote

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.
Back to top
Anonymous
Guest





PostPosted: Thu Dec 23, 2004 6:02 am    Post subject: Function precision: Double vs Extended Reply with quote

This seems to be fixed in version 4.7.0.

- Miguel.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
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