|
forums.silverfrost.com Welcome to the Silverfrost forums
|
View previous topic :: View next topic |
Author |
Message |
Kenneth_Smith
Joined: 18 May 2012 Posts: 697 Location: Hamilton, Lanarkshire, Scotland.
|
Posted: Mon Jun 30, 2014 4:17 pm Post subject: Max value of EXP(x) with x defined with KIND = 3 |
|
|
If I define a real constant x, with KIND =1 (i.e. REAL*4), then the maximum value of EXP(x) which does not cause a floating point exception is approximately x = 88. I can understand this as e**88 is just less than HUGE(x) for KIND =1.
Defining x with KIND = 2 (i.e. REAL*8 ), then the maximum value of EXP(x) increases to x = 709, with EXP(x) now being just less than HUGE(x) for KIND = 2.
Selecting KIND =3, I was anticipating an increase in x, beyond 709 as HUGE(x) for KIND = 3 is much larger. But this does not appear to be the case, and I’m curious as to why this is so?
Defining X as REAL(SELECTED_REAL_KIND(18,4931)) X , does not appear to help.
Cheers
Ken |
|
Back to top |
|
|
davidb
Joined: 17 Jul 2009 Posts: 560 Location: UK
|
Posted: Mon Jun 30, 2014 7:43 pm Post subject: |
|
|
Can you run the following code.
Code: |
Program real_kinds
! Consider reals of the three kinds
real (1) :: x
real (2) :: y
real (3) :: z
! Print their ranges and precisions
print *,' kind 1 range ', range(x), ' precision ', precision(x), ' Huge ', huge(x)
print *,' kind 2 range ', range(y), ' precision ', precision(y), ' Huge ', huge(y)
print *,' kind 3 range ', range(z), ' precision ', precision(z), ' Huge ', huge(z)
print *,' Approx kind 1 max ', 10.0_1**range(x), ' Approx max x in exp(x) ', log(10.0_1**range(x))
print *,' Approx kind 2 max ', 10.0_2**range(y), ' Approx max y in exp(y) ', log(10.0_2**range(y))
print *,' Approx kind 3 max ', 10.0_3**range(z), ' Approx max z in exp(z) ', log(10.0_3**range(z))
End Program real_kinds
|
I get:
kind 1 range 37 precision 6 Huge 3.402823E+38
kind 2 range 307 precision 15 Huge 1.797693134862E+0308
kind 3 range 4931 precision 18 Huge 1.18973149535723177E+4932
Approx kind 1 max 1.000000E+37 Approx max x in exp(x) 85.1956
Approx kind 2 max 1.000000000000E+0307 Approx max y in exp(y) 706.893623549
Approx kind 3 max 1.00000000000000001E+4931 Approx max z in exp(z) 11354.047093553639
So you should be able to calculate exp(z) with z approx. 11354 with kind 3.
Since you can't calculate exp(11354.0_3), this could be a bug in the compiler.
As a workaround you can use exp(1.0_3)**11354.0_3, which seems to work.
Hopefully Paul can put this on his investigate list _________________ Programmer in: Fortran 77/95/2003/2008, C, C++ (& OpenMP), java, Python, Perl |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7927 Location: Salford, UK
|
Posted: Mon Jun 30, 2014 8:43 pm Post subject: |
|
|
I have fixed this bug for the next release. |
|
Back to top |
|
|
Kenneth_Smith
Joined: 18 May 2012 Posts: 697 Location: Hamilton, Lanarkshire, Scotland.
|
Posted: Mon Jun 30, 2014 10:03 pm Post subject: |
|
|
Thanks guys. I was pulling my hair out over this on Sunday.
Cheers
Ken |
|
Back to top |
|
|
|
|
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
|