whole number constants
- From: dancerchris@xxxxxxxxxxxxx
- Date: Mon, 21 Jul 2008 14:16:11 -0700 (PDT)
This may be a dumb question but what is "best practice" when coding
whole numbers in real (kind specified) formulas. I am looking for
accuracy, consistancy and prortability reagardless of what value dp
has below. Many of my calcs have numerical cancellations or accuracy
checks as per the error function below. What are the pitfalls?
for example:
integer, parameter :: dp = selected_real_kind(15, 307)
real(dp) :: x,xnew
real(dp), parameter :: one = 1.0_dp
real(dp), parameter :: onend = 1_dp
real(dp), parameter :: onenk = 1.0
real(dp), parameter :: onei = 1
! which should I use ?
10 error = one-xnew/x
20 error = onend-xnew/x
30 error = onenk-xnew/x
40 error = onei-xnew/x
! or the more ledgable ?
50 error = 1-xnew/x
! or the slightly less ledgable ?
60 error = 1_dp-xnew/x
Thanks for any advice.
.
- Follow-Ups:
- Re: whole number constants
- From: *** Hendrickson
- Re: whole number constants
- From: Craig Powers
- Re: whole number constants
- Prev by Date: Re: Is it time to legitimise REAL*8 etc?
- Next by Date: Re: whole number constants
- Previous by thread: cheap air jordan 22 PayPal
- Next by thread: Re: whole number constants
- Index(es):