bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: checking whether a double is in the range of long


From: Ben Pfaff
Subject: Re: checking whether a double is in the range of long
Date: Sat, 22 Apr 2023 17:55:00 -0700

On Sat, Apr 22, 2023 at 5:52 PM Bruno Haible <bruno@clisp.org> wrote:
>
> Ben Pfaff wrote:
> > determine whether converting 'd' to 'long' would
> > yield a 'long' with the same value as 'd'.
>
> Maybe
>   d == (double) (long) d
> ?
>
> Just a wild guess. I haven't tested it.

I don't trust the undefined behavior in conversions that go outside the
valid range. The program I showed gave me different output with and
without GCC optimization turned on, for example.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]