Re: checking if a floating point number is equal in value to an integer
- From: glen herrmannsfeldt <gah@xxxxxxxxxxxxxxxx>
- Date: Tue, 30 Jan 2007 03:12:21 -0800
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
.
- References:
- checking if a floating point number is equal in value to an integer
- From: analyst41
- Re: checking if a floating point number is equal in value to an integer
- From: glen herrmannsfeldt
- Re: checking if a floating point number is equal in value to an integer
- From: Ugo
- checking if a floating point number is equal in value to an integer
- Prev by Date: Re: Declaration to get 8-bit (or 16-bit) integer?
- Next by Date: Re: Handling large datasets in Fortran
- Previous by thread: Re: checking if a floating point number is equal in value to an integer
- Index(es):