On Sat, Apr 22, 2023 at 10:40 PM Paul Eggert <egg...@cs.ucla.edu> wrote:
> On 2023-04-22 16:34, Ben Pfaff wrote:
> > determine whether converting 'd' to 'long' would
> > yield a 'long' with the same value as 'd'
>
> LONG_MIN - 1.0 < d && d < LONG_MAX + 1.0 && d == (long) d
>
> On all practical platforms this should avoid undefined behavior and
> works correctly even if rounding occurs. You can replace "d == (long) d"
> with "d == floor (d)" if you prefer.

That's much simpler. Thank you.

Reply via email to