Am 23.03.2013 11:30, schrieb Daniel Feenberg:
> Just guessing, but perhaps the reason is that the system can't
> represent exactly all the integers that floor(double) might need to
> be correct. Note that double precision reals have a range far above
> the level at which every integer has an exact representation.
> Possibly 19999999999 doesn't have an exact binary representation, so
> the system doesn't want to promise to evaluate floor(19999999999.5).
Well, int(), nint() etc. works fine with both kind=4 and 8. And floor is
essentially the same as int for positive arguments and int-1 for
negative ones with non-zero decimal fraction. I am using this
construction frequently, since in my work I need a floor-like rounding
more often than simpla truncation.
It is clear that double precision has a larger range than integers (this
is true for single precision, which goes to about 10^38, as well), but
for those below 2^31-1 I see no reason to refuse operation. In addition,
a function which returns the floor value as double precision again would
solve the problem either.
I guess that someone has simply forgotten to implement automatic type
detection in floor/ceiling, either the developers of gfortran or of the
F95 standard itself (and gfortran simply sticks to this standard).
Best wishes,
Ingo