Re: Rounding off double precision
- From: glen herrmannsfeldt <gah@xxxxxxxxxxxxxxxx>
- Date: Sun, 30 Mar 2008 11:26:24 -0800
Charles Coldwell wrote:
(snip, I wrote)
C uses #define is places where Fortran uses PARAMETER,
but #define is typeless.
There's a little more to it than that. In C, the literal constant "0.1"(snip)
has type double precision, in Fortran, the literal constant "0.1" has
type single precision. So
Actually, now that I look at it, the OP actually had the opposite
problem, analogous to
X = 0.1D0
where X is implicitly typed default real (single precision), but the
literal constant has type double precision.
Well, the OP had:
double precision Speed, Azimuth, V
Azimuth = 90.
parameter(Pi = 3.141592653589793238d0)
V = Speed * cos(Azimuth * Pi / 180.)
A double precision constant as a single precision PARAMETER
used in a double precision expression. The C equivalent
#define PI 3.141592653589793238
as you say, the constant is double precision (without an f),
but PI itself is typeless. You can do things like:
#define ABS(x,y) ((x)>(y)?(x):(y))
as a typeless absolute value in C89. (It wont' work for complex
types in C99.)
-- glen
.
- Follow-Ups:
- Re: Rounding off double precision
- From: Chip Coldwell
- Re: Rounding off double precision
- From: Louis Krupp
- Re: Rounding off double precision
- References:
- Rounding off double precision
- From: Bamm
- Re: Rounding off double precision
- From: Bamm
- Re: Rounding off double precision
- From: Richard Maine
- Re: Rounding off double precision
- From: Bamm
- Re: Rounding off double precision
- From: e p chandler
- Re: Rounding off double precision
- From: Bamm
- Re: Rounding off double precision
- From: glen herrmannsfeldt
- Re: Rounding off double precision
- From: Charles Coldwell
- Rounding off double precision
- Prev by Date: Re: Reference to derived type element by index?
- Next by Date: Re: data with metadata
- Previous by thread: Re: Rounding off double precision
- Next by thread: Re: Rounding off double precision
- Index(es):
Relevant Pages
|