Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Re: Rounding off double precision
On Mar 31, 1:55 pm, Dave Seaman <dsea...@no.such.host> wrote:
> On Mon, 31 Mar 2008 08:15:21 -0700 (PDT), Chip Coldwell wrote: 
> 
> 
>
> Ok, it creates an absolutely useless literal constant with a double
> precision value that can't be referenced anywhere.  Is that better?

The whole point of my post was that there are two ways to go wrong in
one of these parameter statements. You can assign a double precision
literal constant to a single precision named parameter:

REAL PI
PARAMETER(PI=3.141592653589793238d0)

Or, you can assign a single precision literal constant to a double
precision named parameter:

DOUBLE PRECISION PI
PARAMETER(PI=3.141592653589793238)

The result in either case is a single precision *value* stored in
either a single- or double-precision named parameter.

So I think the distinction between a literal constant and a named
parameter is relevant to the discussion.

Chip

Report this thread to moderator Post Follow-up to this message
Old Post
Chip Coldwell
04-01-08 03:01 AM


Re: Rounding off double precision
>  A parameter is not a literal constant and vice-versa.

what's the difference? I thought parameter was fortran's way of
declaring a constant.

Report this thread to moderator Post Follow-up to this message
Old Post
Bamm
04-01-08 03:02 AM


Re: Rounding off double precision
On Mon, 31 Mar 2008 19:43:46 -0700 (PDT), Bamm wrote: 

> what's the difference? I thought parameter was fortran's way of
> declaring a constant.

A parameter is a symbolic constant, not a literal constant.


--
Dave Seaman
Court affirms Judge Yohn's ruling.
<http://www.ipsnews.net/news.asp?idnews=41761>

Report this thread to moderator Post Follow-up to this message
Old Post
Dave Seaman
04-01-08 09:49 AM


Re: Rounding off double precision


"Dave Seaman" <dseaman@no.such.host> wrote in message
news:fssah4$iv8$2@mailhub227.itcs.purdue.edu...
> On Mon, 31 Mar 2008 19:43:46 -0700 (PDT), Bamm wrote: 
> 
>
> A parameter is a symbolic constant, not a literal constant.
I think illustrative source snippets go a long way:
INTEGER, PARAMETER :: dp = kind(1d0)
is probably the parameter I get the most mileage from.
--

"I am waiting for them to prove that God is really American."

~~  Lawrence Ferlinghetti



Report this thread to moderator Post Follow-up to this message
Old Post
Gerry Ford
04-01-08 09:49 AM


Re: Rounding off double precision
Organization: School of Math and Comp Sci, Victoria Uni. of Wellington, New 
Zealand.
X-Newsreader: trn 4.0-test76 (Apr 2, 2001)
From: harper@mcs.vuw.ac.nz (John Harper)
Message-ID: <1207023311.687963@bats.mcs.vuw.ac.nz>
Cache-Post-Path: bats.mcs.vuw.ac.nz!unknown@cayley.mcs.vuw.ac.nz
X-Cache: nntpcache 3.0.2 (see http://www.nntpcache.com/)
X-Original-NNTP-Posting-Host: bats.mcs.vuw.ac.nz
Date: 1 Apr 2008 17:15:11 +1300
X-Original-Trace: 1 Apr 2008 17:15:11 +1300, bats.mcs.vuw.ac.nz
Lines: 19
X-Usenet-Provider: http://www.giganews.com
NNTP-Posting-Host: 203.97.37.6
X-AuthenticatedUsername: news10531
X-Trace: sv3- LqbA6X8+gV0GDBcHRhhG9NGjOlS2pSsvVlT3SQoN
oLVg4eFaqiECqWPYBRx8jFz
 f97RUI0Nl6UvQQ6o!reFuQTbHySmX+5PdO71yrMv
weTb/qcVFud2YuPsRyrJdecMQ6hhteJzdEFq
2/rBNG+1u+Zk7/uc=
X-Complaints-To: abuse@clear.net.nz
X-DMCA-Complaints-To: abuse@clear.net.nz
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint
 properly
X-Postfilter: 1.3.38
Bytes: 2456
Xref: number1.nntp.dca.giganews.com comp.lang.fortran:175499

In article <6d59066b-e3dd-4e10-9e1e-f98ce2ca0224@e23g2000prf.googlegroups.co
m>,
Bamm  <bammster@gmail.com> wrote: 
>
>what's the difference? I thought parameter was fortran's way of
>declaring a constant.

Nearly right. It's Fortran's way of declaring a named constant. Constants
are of two kinds: named and literal constants. In the statement
INTEGER, PARAMETER :: two = 2
two is a named constant, and 2 is a literal constant. The difference
sometimes matters, e.g. the next statement may be
CHARACTER stuff*2
but it must not be CHARACTER stuff*two though it may be
CHARACTER stuff*(two)

-- John Harper, School of Mathematics, Statistics and Computer Science,
Victoria University, PO Box 600, Wellington 6140, New Zealand
e-mail john.harper@vuw.ac.nz phone (+64)(4)463 6780 fax (+64)(4)463 5045

Report this thread to moderator Post Follow-up to this message
Old Post

04-01-08 09:49 AM


Re: Rounding off double precision
"Dave Seaman" <dseaman@no.such.host> wrote in message
news:fsr8r6$uu8$3@mailhub227.itcs.purdue.edu...
> On Mon, 31 Mar 2008 17:45:41 +0100, Les wrote:
>
> 
> 
> 
>
> That, of course, is the preferred Fortran 90 syntax, but the Fortran 77
> method
>
> double precision pi
> parameter (pi = 3.14159265358979d0)
>
> also has the desired effect and is closer to what was originally asked.
>

Oops. Yes of course.
Les

>
>
>
> --
> Dave Seaman
> Court affirms Judge Yohn's ruling.
> <http://www.ipsnews.net/news.asp?idnews=41761>



Report this thread to moderator Post Follow-up to this message
Old Post
Les
04-01-08 09:49 AM


Re: Rounding off double precision
On Mon, 31 Mar 2008 22:04:56 -0700, Gerry Ford wrote:



> "Dave Seaman" <dseaman@no.such.host> wrote in message
> news:fssah4$iv8$2@mailhub227.itcs.purdue.edu... 
> I think illustrative source snippets go a long way:
> INTEGER, PARAMETER :: dp = kind(1d0)
> is probably the parameter I get the most mileage from.

And in your example, "dp" is a symbolic constant and "1d0" is a literal
constant.


--
Dave Seaman
Court affirms Judge Yohn's ruling.
<http://www.ipsnews.net/news.asp?idnews=41761>

Report this thread to moderator Post Follow-up to this message
Old Post
Dave Seaman
04-02-08 03:39 AM


Re: Rounding off double precision

"Dave Seaman" <dseaman@no.such.host> wrote in message
news:fstcm0$4eh$1@mailhub227.itcs.purdue.edu...
> On Mon, 31 Mar 2008 22:04:56 -0700, Gerry Ford wrote:
>
>
> 
>
> And in your example, "dp" is a symbolic constant and "1d0" is a literal
> constant.
I didn't know that.

INTEGER, PARAMETER :: qp = kind(???)

Is there an analogous literal here?  It sounds like I'm trying to buy
pot.:-)

--

"That this social order with its pauperism, famines, prisons, gallows,
armies, and wars is necessary to society; that still greater disaster
would ensue if this organization were destroyed; all this is said only
by those who profit by this organization, while those who suffer from it
- and they are ten times as numerous - think and say quite the contrary."

~~  Leo Tolstoy



Report this thread to moderator Post Follow-up to this message
Old Post
Gerry Ford
04-03-08 11:27 AM


Sponsored Links




Last Thread Next Thread Next
Pages (4): « 1 2 3 [4]
Search this forum -> 
Post New Thread

Fortran archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 02:18 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.