Re: compilation problem with module function interface definition
- From: "James Giles" <jamesgiles@xxxxxxxxxxxxxxxx>
- Date: Thu, 28 Apr 2005 23:07:05 GMT
glen herrmannsfeldt wrote:
> Richard E Maine wrote:
....
>> The simplest and most problematic case is the precision of real
>> literal constants. If you have something like
>
>> x = 1.23
>
>> then the 1.23 is single precision, because that's the form of a
>> single precision constant. It does *NOT* matter what the precision
>> of x is; the single precision constant is defined without regard
>> to context. The constant 1.23 is always single precision
>> regardless of where it appears. It is fairly common for people to
>> expect 1.23 to be accurate to double precision if x is double
>> precision.
>
> The C answer to this was to always make constants double. ANSI C
> added the ability to specify single precision with a suffix f.
> Also, C normally promotes function arguments to double before
> calls, unless a prototype declaring the argument as float is in
> scope.
My own preprocessor treats KINDless literals as type RATIONAL.
Mixed mode between RATIONAL and REAL gives a REAL result
of the appropriate precision. So, 1.23 is *EXACTLY* 123/100,
which is then converted to REAL of the same precision as X when
the above assignement is done. (The actual conversion is done
in the preprocessor in this case since the argument to the conversion
is a statically known.)
--
J. Giles
"I conclude that there are two ways of constructing a software
design: One way is to make it so simple that there are obviously
no deficiencies and the other way is to make it so complicated
that there are no obvious deficiencies." -- C. A. R. Hoare
.
- Follow-Ups:
- Re: compilation problem with module function interface definition
- From: glen herrmannsfeldt
- Re: compilation problem with module function interface definition
- From: Gerald F. Thomas
- Re: compilation problem with module function interface definition
- References:
- compilation problem with module function interface definition
- From: Phony Account
- Re: compilation problem with module function interface definition
- From: Richard E Maine
- Re: compilation problem with module function interface definition
- From: Phony Account
- Re: compilation problem with module function interface definition
- From: Richard E Maine
- Re: compilation problem with module function interface definition
- From: glen herrmannsfeldt
- compilation problem with module function interface definition
- Prev by Date: Re: compilation problem with module function interface definition
- Next by Date: Re: COMPUTATIONAL FLUID DYNAMICS - Help with SIMPLE algorithm implementation
- Previous by thread: Re: compilation problem with module function interface definition
- Next by thread: Re: compilation problem with module function interface definition
- Index(es):
Relevant Pages
|