Re: checking if a floating point number is equal in value to an integer



Ugo wrote:

On Jan 30, 5:41 am, glen herrmannsfeldt <g...@xxxxxxxxxxxxxxxxxxxxxxx> wrote:

The aint() function has real type, giving the truncated value
as type real (of the appropriate kind for versions that support
kind). So I would suggest aint(a)==a as the test over
float(nint(a))==a.

And do not forget the standard intrinsic function anint, which gives the closest whole number, like an integer, but of type real.
aint is analogous of int, but with real type
anint is analogous of nint, but with real type

But since the test is for equality, in both cases they
should be equal only for integral values. Reasonably
likely, aint() is simpler and faster. (It is one
instruction on S/360, I don't know it on any others.)

-- glen

.